/**
	* \file			OptionsScreen.cpp
	* \brief		Helper class which takes care of displaying
	*           the INI file options and allowing the user to change them
	*
	*/

//= I N C L U D E S ====================================================
#include "OptionsScreen.h"
#include "ScreensaverScreen.h"
#include "DebugLogger.h"
#include "XBFont.h"
#include "xbox_FileIO.h"
#include "xbox_Network.h"
#include "xbox_Direct3DRenderer.h"
#include "GFilterManager.h"
#include "GraphicsManager.h"
#include "xmvhelper.h"
#include "MusicManager.h"
#include "ROMListScreen.h"

#include "xbox_FileIO.h"		// for path info

#include <string>

extern "C" {
#include "osdepend.h"
#include "driver.h"
#include "virtualmemory.h"
}


//= D E F I N E S ======================================================


  //--- Layout defines -----------------------------------------
#define VIRTUALKEYBOARD_WIDTH     347
#define VIRTUALKEYBOARD_HEIGHT    143

#define STARTPAGE()                       if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_SCROLLAREA_SINGLEROW_OPTIONNAME_TEXT ) && CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_SCROLLAREA_SINGLEROW_OPTIONVALUE_TEXT ) ) { \
																						DWORD i = 0; \
																						const CSkinScrollArea *area = g_loadedSkin->GetSkinElementScrollArea( SKINELEMENT_OPTIONSSCREEN_BODY_SCROLLAREA ); \
																						const CSkinText *nameText = g_loadedSkin->GetSkinElementText( SKINELEMENT_OPTIONSSCREEN_BODY_SCROLLAREA_SINGLEROW_OPTIONNAME_TEXT ); \
																						const CSkinText *valText = g_loadedSkin->GetSkinElementText( SKINELEMENT_OPTIONSSCREEN_BODY_SCROLLAREA_SINGLEROW_OPTIONVALUE_TEXT ); \
																						m_maxPageSize = area->GetHeight() / area->m_singleRowHeight;

#define DRAWITEM( _name__, _val__ )					nameText->RenderAsOffset( m_displayDevice, _name__, area->m_left, area->m_top + (i * area->m_singleRowHeight) ); \
																						valText->RenderAsOffset( m_displayDevice, _val__, area->m_left, area->m_top + (i * area->m_singleRowHeight) ); \
																						++i;

#define ENDPAGE()													}


	// Number of seconds between valid DPAD readings
#define DPADCURSORMOVE_TIMEOUT	0.20f

  // Number of seconds between valid left/right trigger readings
#define TRIGGERSWITCH_TIMEOUT   0.5f


//= G L O B A L = V A R S ==============================================
extern "C" {
  extern const char *cheatfile;
//  extern const char *history_filename;  // Defined in datafile.c
}

extern BOOL g_soundEnabled; // Sound processing override, defined in xbox_Main.cpp
//static UINT32 g_samplerates[2] = { 22700, 44100 };

extern UINT32 g_screensaverTimeout; // Defined in main.cpp

extern void stopMovie();
static CMusicManager*  m_pMusicManager;    // Music Manager

//= P R O T O T Y P E S ===============================================
void Die( LPDIRECT3DDEVICE8 pD3DDevice, const char *fmt, ... );


//= S T R U C T U R E S ===============================================

//= F U N C T I O N S ==================================================

//------------------------------------------------------------
// Constructor
//------------------------------------------------------------
COptionsScreen::COptionsScreen( LPDIRECT3DDEVICE8	displayDevice, 
                            CFontSet &fontSet, 
                            GameOptions &options ) :
  CListView( displayDevice, fontSet, ASSET_LIST_BACKDROP ),
  m_optToggleDelay( 0.0f ),
  m_triggerDelay( 0.0f ),
  m_pageNumber( 0 ),
  m_virtualKeyboardMode( FALSE )
  {

	wcscpy( m_pageData[OPTPAGE_VIDEO].m_title, L"BASIC SETTINGS  ::  Press Back To Return To The Games" );
  m_pageData[OPTPAGE_VIDEO].m_drawFunct = ::DrawVideoPage;
  m_pageData[OPTPAGE_VIDEO].m_changeFunct = ::ChangeVideoPage;
  m_pageData[OPTPAGE_VIDEO].m_numItems = 15; // Basic Number of Lines


  wcscpy( m_pageData[OPTPAGE_GENERAL].m_title, L"VISUAL SETTINGS  ::  Press Back To Return To The Games" );
  m_pageData[OPTPAGE_GENERAL].m_drawFunct = ::DrawGeneralPage;
  m_pageData[OPTPAGE_GENERAL].m_changeFunct = ::ChangeGeneralPage; // Visual Number of Lines
   m_pageData[OPTPAGE_GENERAL].m_numItems = 15;

  wcscpy( m_pageData[OPTPAGE_SOUND].m_title, L"Left Trigger For Basic Settings" );
  m_pageData[OPTPAGE_SOUND].m_drawFunct = ::DrawSoundPage;
  m_pageData[OPTPAGE_SOUND].m_changeFunct = ::ChangeSoundPage;
  m_pageData[OPTPAGE_SOUND].m_numItems = 4;

//HK$ add 2 new option
  wcscpy( m_pageData[OPTPAGE_VECTOR].m_title, L"Right Trigger For Visual Settings" );
  m_pageData[OPTPAGE_VECTOR].m_drawFunct = ::DrawVectorPage;
  m_pageData[OPTPAGE_VECTOR].m_changeFunct = ::ChangeVectorPage;
  m_pageData[OPTPAGE_VECTOR].m_numItems = 6;

  wcscpy( m_pageData[OPTPAGE_NETWORK].m_title, L"Right Trigger For Advanced Settings" );
  m_pageData[OPTPAGE_NETWORK].m_drawFunct = ::DrawNetworkPage;
  m_pageData[OPTPAGE_NETWORK].m_changeFunct = ::ChangeNetworkPage;
  m_pageData[OPTPAGE_NETWORK].m_numItems = 5;

  wcscpy( m_pageData[OPTPAGE_DIRECTORIES_1].m_title, L"Left Trigger For Visual Settings" );
  m_pageData[OPTPAGE_DIRECTORIES_1].m_drawFunct = ::DrawDirectoryPathPage1;
  m_pageData[OPTPAGE_DIRECTORIES_1].m_changeFunct = ::ChangeDirectoryPathPage1;
  m_pageData[OPTPAGE_DIRECTORIES_1].m_numItems = 15; 

  wcscpy( m_pageData[OPTPAGE_DIRECTORIES_2].m_title, L"ADVANCED SETTINGS  ::  Press Back To Return To The Games" );
  m_pageData[OPTPAGE_DIRECTORIES_2].m_drawFunct = ::DrawDirectoryPathPage2;
  m_pageData[OPTPAGE_DIRECTORIES_2].m_changeFunct = ::ChangeDirectoryPathPage2;
  m_pageData[OPTPAGE_DIRECTORIES_2].m_numItems = 15; // Hidden Number of Lines


//HK$ add 2 new option
  wcscpy( m_pageData[OPTPAGE_ROMLIST].m_title, L"EXTRA ADVANCED SETTINGS  ::  Press Back To Return To The Games" );
  m_pageData[OPTPAGE_ROMLIST].m_drawFunct = ::DrawROMListPage;
  m_pageData[OPTPAGE_ROMLIST].m_changeFunct = ::ChangeROMListPage;
  m_pageData[OPTPAGE_ROMLIST].m_numItems = 15;

  wcscpy( m_pageData[OPTPAGE_VMM].m_title, L"Left Trigger For Advanced Settings" );
  m_pageData[OPTPAGE_VMM].m_drawFunct = ::DrawVMMPage;
  m_pageData[OPTPAGE_VMM].m_changeFunct = ::ChangeVMMPage;
  m_pageData[OPTPAGE_VMM].m_numItems = 4;



  RECT area = { 320 - (VIRTUALKEYBOARD_WIDTH>>1), 240 - (VIRTUALKEYBOARD_HEIGHT >> 1), 
                320 + (VIRTUALKEYBOARD_WIDTH>>1), 240 + (VIRTUALKEYBOARD_HEIGHT >> 1) };
  m_virtualKeyboard = new CVirtualKeyboardView( displayDevice, fontSet, area );
}

//---------------------------------------------------------------------
//	Destructor
//---------------------------------------------------------------------
COptionsScreen::~COptionsScreen( void ) 
{
  if( m_virtualKeyboard )
    delete m_virtualKeyboard;
}

//---------------------------------------------------------------------
//	MoveCursor
//---------------------------------------------------------------------
void COptionsScreen::MoveCursor( CInputManager &gp, BOOL useSpeedbanding )
{
	static UINT64		lastTime = 0;
	UINT64 curTime = osd_cycles();
	FLOAT elapsedTime = (FLOAT)(curTime - lastTime) / (FLOAT)osd_cycles_per_second();
   stopMovie();
   if ((g_romListOptions.m_advancedlockout == TRUE) && (g_romListOptions.m_progressive == 1))
   {
g_romListOptions.m_progressive = 0;
SaveOptions();
   }
  if( m_virtualKeyboardMode )
  {
    m_virtualKeyboard->MoveCursor( gp );
    m_pageData[m_pageNumber].m_changeFunct( this, TRUE ); // Polls to see if the keyboard is done w/ input

    if( m_virtualKeyboard->IsInputFinished() )
    {
      gp.WaitForNoInput();
      m_virtualKeyboard->Reset();
      m_virtualKeyboardMode = FALSE;
      m_optToggleDelay = TRIGGERSWITCH_TIMEOUT; // Set the delay timer to avoid accepting buttons from the VK
      lastTime = 0;                             // Don't count time spent in VK screen
    }
    else
      return;
  }

		// General idea taken from XMAME
	if( !lastTime )
	{
			// lastTime isn't valid yet, so wait for the next frame
		lastTime = curTime;
		return;
	}
	lastTime = curTime;

		// Decrement the movement timers
	if( m_dpadCursorDelay > 0.0f )
	{
    BYTE arrowKeys[2] = { VK_UP, VK_DOWN };
		m_dpadCursorDelay -= elapsedTime;
    if( m_dpadCursorDelay < 0.0f || 
        !(gp.IsOneOfButtonsPressed( GP_DPAD_UP | GP_DPAD_DOWN | GP_LA_UP | GP_LA_DOWN ) ||
          gp.IsOneOfKeysPressed( arrowKeys, 2 )) )
			m_dpadCursorDelay = 0.0f;
	}

	if( m_optToggleDelay > 0.0f )
	{
    BYTE arrowKeys[4] = { VK_LEFT, VK_RIGHT, VK_RETURN, VK_BACK };
		m_optToggleDelay -= elapsedTime;
    if( m_optToggleDelay < 0.0f || 
        !(gp.IsOneOfButtonsPressed( GP_DPAD_LEFT | GP_DPAD_RIGHT | GP_LA_LEFT | GP_LA_RIGHT | GP_A | GP_B ) ||
          gp.IsOneOfKeysPressed( arrowKeys, 4 )) )
			m_optToggleDelay = 0.0f;
	}

  if( m_triggerDelay > 0.0f )
  {
    BYTE pageKeys[2] = { VK_DELETE, VK_NEXT };
    m_triggerDelay -= elapsedTime;
    if( m_triggerDelay < 0.0f || 
        !(gp.IsOneOfButtonsPressed( GP_LEFT_TRIGGER | GP_RIGHT_TRIGGER ) ||
          gp.IsOneOfKeysPressed( pageKeys, 2 )) )
      m_triggerDelay = 0.0f;
  }

    //-- Check the button states ---------------------------------------------------------- 
	    else if( (gp.IsButtonPressed( GP_LEFT_TRIGGER ) && m_triggerDelay == 0.0f) && m_pageNumber == 7)
  {
       m_pageNumber = 6;
    m_triggerDelay = TRIGGERSWITCH_TIMEOUT;
  }
  else if( (gp.IsButtonPressed( GP_LEFT_TRIGGER ) && m_triggerDelay == 0.0f) && m_pageNumber == 6)
  {
       m_pageNumber = 1;
    m_triggerDelay = TRIGGERSWITCH_TIMEOUT;
  }
    else if( (gp.IsButtonPressed( GP_LEFT_TRIGGER ) && m_triggerDelay == 0.0f) && m_pageNumber == 1)
  {
       m_pageNumber = 0;
    m_triggerDelay = TRIGGERSWITCH_TIMEOUT;
  }
     else if( (gp.IsButtonPressed( GP_RIGHT_TRIGGER ) && m_triggerDelay == 0.0f) && m_pageNumber == 0 && g_romListOptions.m_progressive == 1)
  {
       m_pageNumber = 1;
    m_triggerDelay = TRIGGERSWITCH_TIMEOUT;
  }
       else if( (gp.IsButtonPressed( GP_RIGHT_TRIGGER ) && m_triggerDelay == 0.0f) && m_pageNumber == 1 && g_romListOptions.m_progressive == 1)
  {
       m_pageNumber = 6;
    m_triggerDelay = TRIGGERSWITCH_TIMEOUT;
  }
         else if( (gp.IsButtonPressed( GP_RIGHT_TRIGGER ) && m_triggerDelay == 0.0f) && m_pageNumber == 6 && g_romListOptions.m_progressive == 1)
  {
       m_pageNumber = 7;
    m_triggerDelay = TRIGGERSWITCH_TIMEOUT;
  }
        else if(g_romListOptions.m_progressive == 0 && m_pageNumber == 1)
  {
       m_pageNumber = 0;
  }
          else if(g_romListOptions.m_progressive == 0 && m_pageNumber == 6)
  {
       m_pageNumber = 0;
  }
            else if(g_romListOptions.m_progressive == 0 && m_pageNumber == 7)
  {
       m_pageNumber = 0;
  }



    //-- Check the button states ----------------------------------------------------------
 
  else if( (gp.IsOneOfButtonsPressed( GP_DPAD_DOWN | GP_LA_DOWN ) || gp.IsKeyPressed( VK_DOWN )) && m_dpadCursorDelay == 0.0f )
	{
		m_dpadCursorDelay = DPADCURSORMOVE_TIMEOUT;
    if( ++m_cursorPosition >= m_pageData[m_pageNumber].m_numItems )
      m_cursorPosition = 0;
  }
  else if( (gp.IsOneOfButtonsPressed( GP_DPAD_UP | GP_LA_UP ) || gp.IsKeyPressed( VK_UP )) && m_dpadCursorDelay == 0.0f )
	{
		m_dpadCursorDelay = DPADCURSORMOVE_TIMEOUT;
    if( m_cursorPosition ) 
      --m_cursorPosition;
    else
      m_cursorPosition = m_pageData[m_pageNumber].m_numItems - 1;
  }
  else if( (gp.IsOneOfButtonsPressed( GP_DPAD_LEFT | GP_LA_LEFT | GP_B ) || gp.IsKeyPressed( VK_LEFT ) || gp.IsKeyPressed( VK_BACK )) && 
            m_optToggleDelay == 0.0f )
	{
		m_optToggleDelay = TRIGGERSWITCH_TIMEOUT;
    m_pageData[m_pageNumber].m_changeFunct( this, FALSE );
  }
  else if( (gp.IsOneOfButtonsPressed( GP_DPAD_RIGHT | GP_LA_RIGHT | GP_A ) || gp.IsKeyPressed( VK_RIGHT ) || gp.IsKeyPressed( VK_RETURN )) && 
            m_optToggleDelay == 0.0f )
	{
		m_optToggleDelay = TRIGGERSWITCH_TIMEOUT;
    m_pageData[m_pageNumber].m_changeFunct( this, TRUE );
  }
  
}


//---------------------------------------------------------------------
//	Draw
//---------------------------------------------------------------------
void COptionsScreen::Draw( BOOL clearScreen, BOOL flipOnCompletion )
{

stopMovie();
	  if( clearScreen )  
	  m_displayDevice->Clear(	0L,																// Count
		  											NULL,															// Rects to clear
			  										D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,	// Flags
				  									D3DCOLOR_XRGB(0,0,0),							// Color
					  								1.0f,															// Z
						  							0L );															// Stencil

	if( !g_loadedSkin )
		return;

  RenderBackdrop();
	if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_FOOTER ) )
		g_loadedSkin->GetSkinElement( SKINELEMENT_OPTIONSSCREEN_FOOTER )->Render( m_displayDevice );

	if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY ) )
		g_loadedSkin->GetSkinElement( SKINELEMENT_OPTIONSSCREEN_BODY )->Render( m_displayDevice );

	if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_HEADER ) )
		g_loadedSkin->GetSkinElement( SKINELEMENT_OPTIONSSCREEN_HEADER )->Render( m_displayDevice );



		//-- Draw the help text --------------------------------------------

		// ** Start ** //



		//--- Draw the title bar text --------------------------------------
	FLOAT titleBarLeft = 0.0f;
	FLOAT titleBarTop = 0.0f;
	if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_HEADER ) )
	{
		const CSkinElement *titleBarArea = g_loadedSkin->GetSkinElement( SKINELEMENT_OPTIONSSCREEN_HEADER );
		titleBarLeft = titleBarArea->m_left;
		titleBarTop =  titleBarArea->m_top;
	}

	if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_HEADER_TEXT ) )
		g_loadedSkin->GetSkinElementText( SKINELEMENT_OPTIONSSCREEN_HEADER_TEXT )->RenderAsOffset(	m_displayDevice, 
																																																m_pageData[m_pageNumber].m_title, 
																																																titleBarLeft, 
																																																titleBarTop );

			// Draw the spacer
	// if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_HEADER_DIVIDER ) )
	// {
	// 	g_loadedSkin->GetSkinElementDivider(SKINELEMENT_OPTIONSSCREEN_HEADER_DIVIDER)->RenderAsOffset( m_displayDevice, 
	//																																																 titleBarLeft, 
	//																																																 titleBarTop );
	// }

		//--- Draw the body text -------------------------------------------
	if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_SCROLLAREA ) )
	{
		const CSkinScrollArea *area = g_loadedSkin->GetSkinElementScrollArea( SKINELEMENT_OPTIONSSCREEN_BODY_SCROLLAREA );
		m_maxPageSize = area->GetHeight() / area->m_singleRowHeight;

			// Render the highlight bar for the selected item
		FLOAT selectedItemYPos = area->m_top + (area->m_singleRowHeight * (UINT32)m_cursorPosition);
		if( area->m_highlightBar )
			area->m_highlightBar->RenderAsOffset( m_displayDevice, area->m_left, selectedItemYPos );

			// Draw the spacer
	//	if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_DIVIDER ) )
	//	{
	//		FLOAT left = 0.0f;
	//		FLOAT top = 0.0f;
	//		const CSkinElement *bodyArea = g_loadedSkin->GetSkinElement( SKINELEMENT_OPTIONSSCREEN_BODY );
	//		if( bodyArea )
	//		{
	//			left = bodyArea->m_left;
	//			top = bodyArea->m_top;
	//		}
//
//			g_loadedSkin->GetSkinElementDivider(SKINELEMENT_OPTIONSSCREEN_BODY_DIVIDER)->RenderAsOffset( m_displayDevice, 
//																																																	 left, 
//																																																	 top );
//		}


		m_pageData[m_pageNumber].m_drawFunct( this );

    //-- Draw the trigger icons -----------------------------------------------------------

			// Calculate the previous and next page indices
		UINT32 prevPageIndex = m_pageNumber ? m_pageNumber - 1 : OPTPAGE_LAST - 1; 
		UINT32 nextPageIndex = m_pageNumber < OPTPAGE_LAST - 1 ? m_pageNumber + 1 : 0;

		if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_LEFT )  && m_pageNumber == 1 ) 
			g_loadedSkin->GetSkinElementTriggerInfo(SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_LEFT)->Render( m_displayDevice, m_pageData[2].m_title );

		if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_LEFT )  && m_pageNumber == 6 ) 
			g_loadedSkin->GetSkinElementTriggerInfo(SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_LEFT)->Render( m_displayDevice, m_pageData[5].m_title );

			if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_LEFT )  && m_pageNumber == 7 ) 
			g_loadedSkin->GetSkinElementTriggerInfo(SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_LEFT)->Render( m_displayDevice, m_pageData[8].m_title );

				if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_LEFT )  && m_pageNumber == 6 ) 
			g_loadedSkin->GetSkinElementTriggerInfo(SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_RIGHT)->Render( m_displayDevice, m_pageData[4].m_title );

		if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_RIGHT )   && m_pageNumber == 0  && g_romListOptions.m_progressive == 1 )
			g_loadedSkin->GetSkinElementTriggerInfo(SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_RIGHT)->Render( m_displayDevice, m_pageData[3].m_title );

		
		if( CheckResourceValidity( SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_RIGHT )   && m_pageNumber == 1  && g_romListOptions.m_progressive == 1 )
			g_loadedSkin->GetSkinElementTriggerInfo(SKINELEMENT_OPTIONSSCREEN_BODY_TRIGGERINFO_RIGHT)->Render( m_displayDevice, m_pageData[4].m_title );



	
	}

  if( m_virtualKeyboardMode )
    m_virtualKeyboard->Draw( FALSE, FALSE );

  if( flipOnCompletion )
	  m_displayDevice->Present( NULL, NULL, NULL, NULL );	
}

//---------------------------------------------------------------------
//	DrawGeneralPage  // Ken ***VISUAL NAMES***
//---------------------------------------------------------------------
void COptionsScreen::DrawGeneralPage( void )
{
	WCHAR text[256] = {0};
    WCHAR bios[256] = {0};
	WCHAR name[256] = {0};


  switch (options.choosebios) {
	  case 0 : 	swprintf(bios,L"Disabled");
		        break;
	  case 1 : 	swprintf(bios,L"Europe V1");
		        break;
	  case 2 : 	swprintf(bios,L"US V2");
		        break;
	  case 3 : 	swprintf(bios,L"US V1");
		        break;
	  case 4 : 	swprintf(bios,L"Asia V3");
		        break;
	  case 5 : 	swprintf(bios,L"Japan V3");
		        break;
	  case 6 : 	swprintf(bios,L"Japan V2");
		        break;
	  case 7 : 	swprintf(bios,L"Unibios V1");
		        break;
	  case 8 : 	swprintf(bios,L"Unibios V1.1");
		        break;
	  case 9 : 	swprintf(bios,L"Debug");
		        break;
	  case 10 : 	swprintf(bios,L"Asia AES");
		        break;
	  case 11 : 	swprintf(bios,L"Unibios V1.3");
		        break;
	  case 12 : 	swprintf(bios,L"ENABLED");
		        break;
  }

    const WCHAR filterNames[][16] = { L"Disabled",
                                    L"Disabled", 
                                    L"ENABLED", 
                                    L"Anisotropic", 
                                    L"Quincunx", 
                                    L"Gaussian Cubic" };        
  STARTPAGE();  

	DRAWITEM( L"VIDEO 720P Hi Def Support", g_romListOptions.m_hidefinition ? L"ENABLED" : L"Disabled" ); 
	if (g_rendererOptions.m_FilterType != 0)
	{
	DRAWITEM( L"WARNING!!! VIDEO Enhancing Effects", g_rendererOptions.m_FilterType ? L"ENABLED" : L"Disabled" );
	}
		if (g_rendererOptions.m_FilterType == 0)
	{
	DRAWITEM( L"VIDEO Enhancing Effects", g_rendererOptions.m_FilterType ? L"ENABLED" : L"Disabled" );
	}
	DRAWITEM( L"VIDEO Soften Display", g_rendererOptions.m_SoftDisplayFilter ? L"ENABLED" : L"Disabled" );
	if (g_romListOptions.m_autoalias == TRUE)
	{
	DRAWITEM( L"VIDEO Anti-Aliasing", g_rendererOptions.m_FilterType ? L"Automatic" : L"Automatic" );
	}
		if (g_romListOptions.m_autoalias == false)
	{
	DRAWITEM( L"VIDEO Anti-Aliasing", filterNames[g_rendererOptions.m_minFilter] );
	}
			swprintf( text, L"Level %d", g_rendererOptions.m_FlickerFilter );
	if (g_romListOptions.m_automaticflicker == TRUE)
		{
	DRAWITEM( L"VIDEO Flicker Filter", g_rendererOptions.m_SoftDisplayFilter ? L"Automatic" : L"Automatic" );
		}
	if (g_romListOptions.m_automaticflicker == false)
		{
	DRAWITEM( L"VIDEO Flicker Filter", text );
		}
		swprintf( text, L"Level %d", g_rendererOptions.m_frameskip );
	DRAWITEM( L"VIDEO Frameskip",g_rendererOptions.m_frameskip == AUTO_FRAMESKIP ?  L"Automatic" :
            (!g_rendererOptions.m_frameskip ? L"Disabled" : text ) );
					if( !options.use_artwork )
			swprintf( text, L"Disabled" );
			else
			{
			swprintf( text, L"ENABLED" );
			}
	DRAWITEM( L"VIDEO Previews", g_romListOptions.m_videopreview ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"VIDEO Sync Smoothing", g_rendererOptions.m_vsync ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"VIDEO Wide Game Width Tweak", g_romListOptions.m_fixaspect ? L"ENABLED" : L"Disabled" );
	if (g_romListOptions.m_tenbyelevenaspect == false)
	{
	DRAWITEM( L"VIDEO Pixel Ratio 10 x 11", g_romListOptions.m_tenbyelevenaspect ? L"ENABLED" : L"Disabled" );
	}
	if (g_romListOptions.m_tenbyelevenaspect == TRUE)
	{
	DRAWITEM( L"WARNING!!! VIDEO Pixel Ratio 10 x 11", g_romListOptions.m_tenbyelevenaspect ? L"ENABLED" : L"Disabled" );
	}
//	swprintf( text, L"%lu", options.beam );
 //   DRAWITEM( L"VIDEO Vector Beam Width", text );
 //   swprintf( text, L"%f", options.vector_intensity );
 //   DRAWITEM( L"VIDEO Vector Intensity", text );
	if (g_romListOptions.m_picscreensaver == TRUE)
		{
		DRAWITEM( L"SCREENSAVER Mode", g_romListOptions.m_shutdownmode ? L"Game Snapshots" : L"Game Snapshots" ); 
		}

		if ((g_romListOptions.m_shutdownmode == false) && (g_rendererOptions.m_VideoScreenSaver == false) && (g_romListOptions.m_picscreensaver == false))
	{
	DRAWITEM( L"SCREENSAVER Mode", g_romListOptions.m_shutdownmode ? L"Shutdown" : L"Shutdown" ); 
	}
		if ((g_romListOptions.m_shutdownmode == TRUE) && (g_rendererOptions.m_VideoScreenSaver == TRUE) && (g_romListOptions.m_picscreensaver == false))
	{
	DRAWITEM( L"SCREENSAVER Mode", g_romListOptions.m_shutdownmode ? L"Game Videos" : L"Game Videos" ); 
	}
			if ((g_romListOptions.m_shutdownmode == TRUE) && (g_rendererOptions.m_VideoScreenSaver == false) && (g_romListOptions.m_picscreensaver == false))
	{
	DRAWITEM( L"SCREENSAVER Mode", g_romListOptions.m_shutdownmode ? L"Black Out Screen" : L"Black Out Screen" ); 
	}
		swprintf( name, L"After %lu Minute%s", g_screensaverTimeout, g_screensaverTimeout > 1 ? "s" : "" );
		if ((g_romListOptions.m_shutdownmode == TRUE) && (g_rendererOptions.m_VideoScreenSaver == TRUE) && (g_romListOptions.m_picscreensaver == false))
			{
	DRAWITEM( L"SCREENSAVER Random Game Videos", g_screensaverTimeout ? name : L"Disabled" );
			}
					if ((g_romListOptions.m_shutdownmode == TRUE) && (g_rendererOptions.m_VideoScreenSaver == false) && (g_romListOptions.m_picscreensaver == false))
			{
	DRAWITEM( L"SCREENSAVER Blackout Screen", g_screensaverTimeout ? name : L"Disabled" );
			}
		if(( g_romListOptions.m_shutdownmode == 0) && (g_romListOptions.m_picscreensaver == false) )
			{
	DRAWITEM( L"SHUTDOWN The Xbox", g_screensaverTimeout ? name : L"Disabled" );
			}
					if(g_romListOptions.m_picscreensaver == TRUE) 
			{
	DRAWITEM( L"SCREENSAVER Random Game Snapshots", g_screensaverTimeout ? name : L"Disabled" );
			}
	if ( g_romListOptions.m_namegrouping == false )
			{
	DRAWITEM( L"Sort By Name Arcade & Home Merged", g_romListOptions.m_namegrouping ? L"ENABLED" : L"ENABLED" );
			}
	if ( g_romListOptions.m_namegrouping == TRUE ) 
			{
	DRAWITEM( L"Sort By Name Arcade & Home Merged", g_romListOptions.m_namegrouping ? L"Disabled" : L"Disabled" );
			}
						if (g_rendererOptions.m_rotationkeys == false)
			{
	DRAWITEM( L"Screen Mounting", g_rendererOptions.m_rotationkeys ? L"Normal" : L"Normal" );
			}
						if ((g_rendererOptions.m_rotationkeys == TRUE) && (g_rendererOptions.m_OnSide == false))
			{
	DRAWITEM( L"WARNING!!! Screen Mounting", g_rendererOptions.m_rotationkeys ? L"On Right Side" : L"On Right Side" );
			}
									if ((g_rendererOptions.m_rotationkeys == TRUE) && (g_rendererOptions.m_OnSide == TRUE))
			{
	DRAWITEM( L"WARNING!!! Screen Mounting", g_rendererOptions.m_rotationkeys ? L"On Left Side" : L"On Left Side" );
			}
	DRAWITEM( L"WARNING!!! Advanced Settings", g_romListOptions.m_progressive ? L"ENABLED" : L"Disabled" );



	 	//	CGFilterManager oFilterManger;
	// MapFilters mapFilters = oFilterManger.GetAvailableFilters();

 //		CGFilterManager oFilterManger;
//	MapFilters mapFilters = oFilterManger.GetAvailableFilters();
// DRAWITEM( L"VIDEO Enhancing Effects", mapFilters[(EFilterType)g_rendererOptions.m_FilterType].m_strName );   

 // DRAWITEM( L"VIDEO Magnification", filterNames[g_rendererOptions.m_magFilter] ); 
 
//HK$ add option "Soft Display filter"
 
     
	//  DRAWITEM( L"VIDEO Sync Smoothing", g_rendererOptions.m_vsync ? L"ENABLED" : L"Disabled" );
	
//HK$ add option "Flicker filter"
 // swprintf( text, L"Level %d", g_rendererOptions.m_FlickerFilter );
 // DRAWITEM( L"VIDEO Flicker Filter", text );
 // 				swprintf( text, L"Level %d", g_rendererOptions.m_frameskip );
 // DRAWITEM( L"VIDEO Frameskip", 
 //           g_rendererOptions.m_frameskip == AUTO_FRAMESKIP ?  L"Automatic" :
 //           (!g_rendererOptions.m_frameskip ? L"Disabled" : text ) );
 // DRAWITEM( L"SOUND Lockout Operates Automatically", g_romListOptions.m_autosound ? L"ENABLED" : L"Disabled" );

  //     if( g_romListOptions.m_autosound == 0 )
 // {
 // DRAWITEM( L"SOUND Lockout", g_romListOptions.m_soundlockout ? L"ENABLED" : L"Disabled" );
 // }
 //        if( g_romListOptions.m_autosound == 1 )
 // {
 // DRAWITEM( L"SOUND Lockout", g_romListOptions.m_soundlockout ? L" ------------" : L" ------------" );
 // }
  // DRAWITEM( L"Cheats", options.cheat ? L"Enabled" : L"Disabled" );

  //WCHAR name[256] = {0};
  //	mbstowcs( name, cheatfile, 255 );
  // DRAWITEM( L"Cheat file", name );
/*
  mbstowcs( name, history_filename, 255 );
  DRAWITEM( L"History file", name );
*/
 // DRAWITEM( L"Disclaimer", options.skip_disclaimer ? L"Skipped" : L"Shown" );

 // DRAWITEM( L"Game Info", options.skip_gameinfo ? L"Skipped" : L"Shown" );

  //Ebs skip warnings
 // DRAWITEM( L"Warnings", options.skip_warnings ? L"Skipped" : L"Shown" );

 // swprintf( name, L"After %lu Minute%s", g_screensaverTimeout, g_screensaverTimeout > 1 ? "s" : "" );
 // DRAWITEM( L"Screensaver", g_screensaverTimeout ? name : L"Disabled" );

  // DRAWITEM( L"VIRTUAL MEMORY Configuration", g_forcevmem ? L"ENABLED" : L"Disabled" );

//  swprintf( text, L"%lu MB", g_vmemThreshold / 0x100000 );
 //     if( g_forcevmem == 0 )
//  {
 //  DRAWITEM( L"VIRTUAL MEMORY Threshold", g_vmemThreshold ? L" ------------" : L" ------------" );
 // }
  //    if( g_forcevmem == 1 )
 // {
 // DRAWITEM( L"VIRTUAL MEMORY Threshold", text );
 // }

  //swprintf( text, L"%lu KB", g_vmemCommitSize / 1024 );
   //     if( g_forcevmem == 0 )
  //{
 //  DRAWITEM( L"VIRTUAL MEMORY Commit Size", g_vmemThreshold ? L" ------------" : L" ------------" );
 // }
  //    if( g_forcevmem == 1 )
 // {
 // DRAWITEM( L"VIRTUAL MEMORY Commit Size", text );
 // }

 // swprintf( text, L"%lu", g_vmemDistribute );
    //      if( g_forcevmem == 0 )
 // {
  // DRAWITEM( L"VIRTUAL MEMORY Distribute", g_vmemThreshold ? L" ------------" : L" ------------" );
 // }
  //    if( g_forcevmem == 1 )
 // {
//  DRAWITEM( L"VIRTUAL MEMORY Distribute", text );
//  }


//  DRAWITEM( L"Neo-Geo Custom Bios", bios);
  // DRAWITEM( L"Rotate Vertical Games 90 Degrees", g_romListOptions.m_rotate ? L"ENABLED" : L"Disabled" );



  //	if (g_romListOptions.m_rotate == TRUE  || g_rendererOptions.m_rotationkeys == TRUE )
//		{
//DRAWITEM( L"WIDESCREEN ASPECT RATIO For Rotated Games", g_romListOptions.m_fixaspect ? L"ENABLED" : L"Disabled" ); 
//		}
//			if (g_romListOptions.m_rotate == FALSE && g_rendererOptions.m_rotationkeys == FALSE )
//		{
//DRAWITEM( L"Rotated Games Use Widescreen Aspect Ratio", g_romListOptions.m_fixaspect ? L" ------------" : L" ------------" ); 
//		}
	


//  if( g_romListOptions.m_rotate == TRUE )
//  {
//	DRAWITEM( L"Rotated Games Use Rotated Keys", g_rendererOptions.m_rotationkeys ? L"ENABLED" : L"Disabled" ); 
//  }
//  if( g_romListOptions.m_rotate == FALSE )
//  {
//	  DRAWITEM( L"Rotated Games Use Rotated Keys", g_rendererOptions.m_rotationkeys ? L" ------------" : L" ------------" ); 
//  }

	//DRAWITEM( L"WARNING!!! Advanced Settings", g_romListOptions.m_progressive ? L"ENABLED" : L"Disabled" ); 


  ENDPAGE();
}

//---------------------------------------------------------------------
//	Reset options 
//---------------------------------------------------------------------

void COptionsScreen::ResetOptions( void )
{
  m_cursorPosition = 0;
  m_optToggleDelay = 0;
  m_triggerDelay = 0;
  m_pageNumber = 0;
  m_virtualKeyboardMode = FALSE;
}



//---------------------------------------------------------------------
//	DrawSoundPage
//---------------------------------------------------------------------
void COptionsScreen::DrawSoundPage( void )
{
/*
    // sound sample playback rate, in Hz
  options.samplerate = iniFile.GetProfileInt( "Sound", "SampleRate", 44100 );
    // 1 to enable external .wav samples
  options.use_samples = iniFile.GetProfileInt( "Sound", "UseSamples", TRUE );
    // 1 to enable FIR filter on final mixer output
  options.use_filter = iniFile.GetProfileInt( "Sound", "UseFilter", TRUE );
*/

  WCHAR text[256] = {0};

  STARTPAGE();

  DRAWITEM( L"Sound Processing", g_soundEnabled ? L"Enabled" : L"Disabled" );

  swprintf( text, L"%lu", options.samplerate );
  DRAWITEM( L"Sample Rate", text );

  DRAWITEM( L"Audio Samples", options.use_samples ? L"Enabled" : L"Disabled" );

  DRAWITEM( L"Audio Filter", options.use_filter ? L"Enabled" : L"Disabled" );

  ENDPAGE();
}


//---------------------------------------------------------------------
//	DrawVMMPage
//---------------------------------------------------------------------
void COptionsScreen::DrawVMMPage( void )
{
/*
	g_forcevmem =                    iniFile.GetProfileInt( "VMMOptions", "ForceVMM", FALSE );

	if ( g_forcevmem )
	{
		g_vmemThreshold =                    iniFile.GetProfileInt( "VMMOptions", "Threshold", 0x400000 );
		g_vmemCommitSize =                    iniFile.GetProfileInt( "VMMOptions", "Threshold", 0x100000 );
		g_vmemDistribute =                    iniFile.GetProfileInt( "VMMOptions", "Threshold", 0xFFFF );
	}
*/

  WCHAR text[256] = {0};

  STARTPAGE();

  DRAWITEM( L"Force VMM?", g_forcevmem ? L"Yes" : L"No" );

  swprintf( text, L"%lu MB", g_vmemThreshold / 0x100000 );
  DRAWITEM( L"Threshold", text );

  swprintf( text, L"%lu KB", g_vmemCommitSize / 1024 );
  DRAWITEM( L"Commit Size", text );

  swprintf( text, L"%lu", g_vmemDistribute );
  DRAWITEM( L"Distribute", text );

  ENDPAGE();
}


//---------------------------------------------------------------------
//	DrawVideoPage   // Ken ***BASIC NAMES***
//---------------------------------------------------------------------
void COptionsScreen::DrawVideoPage( void )
{
/*
  g_rendererOptions.m_vsync = iniFile.GetProfileInt( "Video", "VSYNC", FALSE );       // Enable VSYNC for game rendering
  g_rendererOptions.m_syncOnlyToVSYNC
  g_rendererOptions.m_frameskip =           iniFile.GetProfileInt( "Video", "Frameskip", AUTO_FRAMESKIP );
  options.brightness = iniFile.GetProfileFloat( "Video", "Brightness", 1.0f );		    // brightness of the display
  options.pause_bright = iniFile.GetProfileFloat( "Video", "PauseBrightness", 0.65f );     // brightness when in pause
	options.gamma = iniFile.GetProfileFloat( "Video", "Gamma", 1.0f );			        // gamma correction of the display
	options.color_depth = iniFile.GetProfileInt( "Video", "ColorDepth", 32 );
  options.use_artwork = iniFile.GetProfileInt( "Video", "Artwork", 0 );
*/



  WCHAR text[256] = {0};     
  WCHAR name[256] = {0};

   static WCHAR *sortMode[] = {  L"Name ",
                                L"Year of Release ",
                                L"Times Played ", 
								L"Type ",
								L"Manufacturer ",
								L"Arcade or Home ",
								L"Console ",
                                L"Back Button " };


  const WCHAR filterNames[][16] = { L"None",
                                    L"Point", 
                                    L"Linear", 
                                    L"Anisotropic", 
                                    L"Quincunx", 
                                    L"Gaussian Cubic" };

    const WCHAR trackNames[][16] = { L"Random Tracks",
                                    L"Track 1", 
                                    L"Track 2", 
                                    L"Track 3", 
                                    L"Track 4",
									L"Track 5", 
									L"Track 6", 
									L"Track 7", 
									L"Track 8", 
									L"Track 9", 
                                    L"Track 10" };


  STARTPAGE();  
  	
if(( g_romListOptions.m_hot == 1) && (g_romListOptions.m_top == 1))
{
	DRAWITEM( L"FAVORITES All Time Classic And Hot Games Added", g_romListOptions.m_hot ? L"CLASSICS & HOT" : L"CLASSICS & HOT" ); 
}
if(( g_romListOptions.m_hot == 0) && (g_romListOptions.m_top == 0))
{
	DRAWITEM( L"FAVORITES All Time Classic And Hot Games Added", g_romListOptions.m_hot ? L"Disabled" : L"Disabled" ); 
}
if(( g_romListOptions.m_hot == 0) && (g_romListOptions.m_top == 1))
{
	DRAWITEM( L"FAVORITES All Time Classic And Hot Games Added", g_romListOptions.m_hot ? L"CLASSICS" : L"CLASSICS" ); 
}


	if (g_rendererOptions.m_autofiring == false)
			{
	DRAWITEM( L"AUTOFIRE AND SEMI-AUTOMATIC FIRE", g_rendererOptions.m_autofiring ? L"ENABLED" : L"Disabled" );
			}
			if (g_rendererOptions.m_automaticfirea == TRUE)
			{
	DRAWITEM( L"AUTOFIRE AND SEMI-AUTOMATIC FIRE", g_rendererOptions.m_autofiring ? L"GREEN Button ( A )" : L"Disabled" );
			}
						if (g_rendererOptions.m_automaticfireb == TRUE)
			{
	DRAWITEM( L"AUTOFIRE AND SEMI-AUTOMATIC FIRE", g_rendererOptions.m_autofiring ? L"RED Button ( B )" : L"Disabled" );
			}
						if (g_rendererOptions.m_automaticfirex == TRUE)
			{
	DRAWITEM( L"AUTOFIRE AND SEMI-AUTOMATIC FIRE", g_rendererOptions.m_autofiring ? L"BLUE Button ( X )" : L"Disabled" );
			}
						if (g_rendererOptions.m_automaticfirey == TRUE)
			{
	DRAWITEM( L"AUTOFIRE AND SEMI-AUTOMATIC FIRE", g_rendererOptions.m_autofiring ? L"YELLOW Button ( Y )" : L"Disabled" );
			}


if(( g_romListOptions.m_soundtrack == 0) && (g_romListOptions.m_screentitles == 0) && (g_romListOptions.m_pausebgmusic == 0))
{
	DRAWITEM( L"BACKGROUND SOUNDS", g_romListOptions.m_soundtrack ? L"Disabled" : L"Disabled" );
}
if(( g_romListOptions.m_soundtrack == 1) && (g_romListOptions.m_screentitles == 0) && (g_romListOptions.m_pausebgmusic == 0))
{
	DRAWITEM( L"BACKGROUND SOUNDS", g_romListOptions.m_soundtrack ? L"MUSIC" : L"MUSIC" );
}
if(( g_romListOptions.m_soundtrack == 0) && (g_romListOptions.m_screentitles == 1) && (g_romListOptions.m_pausebgmusic == 0))
{
	DRAWITEM( L"BACKGROUND SOUNDS", g_romListOptions.m_soundtrack ? L"VIDEO" : L"VIDEO" );
}
if(( g_romListOptions.m_soundtrack == 1) && (g_romListOptions.m_screentitles == 1) && (g_romListOptions.m_pausebgmusic == 0))
{
	DRAWITEM( L"BACKGROUND SOUNDS", g_romListOptions.m_soundtrack ? L"MUSIC & VIDEO" : L"MUSIC & VIDEO" );
}
if(g_romListOptions.m_pausebgmusic == 1)
{
	DRAWITEM( L"BACKGROUND SOUNDS", g_romListOptions.m_soundtrack ? L"MUSIC If No VIDEO" : L"MUSIC If No VIDEO" );
}
	DRAWITEM( L"BACKGROUND MUSIC", trackNames[(UINT32)g_rendererOptions.m_BackgroundFilter]);
	if ((g_romListOptions.m_showclassic == 0) && (g_romListOptions.m_showhot == 1))
{
	DRAWITEM( L"RANDOM GAME", g_romListOptions.m_soundtrack ? L"Selects Game" : L"Selects Game" );
}
	if ((g_romListOptions.m_showclassic == 0) && (g_romListOptions.m_showhot == 0))
{
	DRAWITEM( L"RANDOM GAME", g_romListOptions.m_soundtrack ? L"Plays Game" : L"Plays Game" );
}
	if ((g_romListOptions.m_showclassic == 1) && (g_romListOptions.m_showhot == 1))
{
	DRAWITEM( L"RANDOM GAME", g_romListOptions.m_soundtrack ? L"Selects Favorite" : L"Selects Favorite" );
}
	if ((g_romListOptions.m_showclassic == 1) && (g_romListOptions.m_showhot == 0))
{
	DRAWITEM( L"RANDOM GAME", g_romListOptions.m_soundtrack ? L"Plays Favorite" : L"Plays Favorite" );
}
if ( g_rendererOptions.m_screenRotation == SR_0)
{
			if (( g_romListOptions.m_rotate == 0) && (g_romListOptions.m_onlyrotateshooters == 0))
			{
	DRAWITEM( L"AUTOROTATE Vertical Games", g_romListOptions.m_onlyrotateshooters ? L"Disabled" : L"Disabled" );
			}
			if (( g_romListOptions.m_rotate == 1) && (g_romListOptions.m_onlyrotateshooters == 0))
			{
	DRAWITEM( L"AUTOROTATE Vertical Games", g_romListOptions.m_onlyrotateshooters ? L"All Vertical Games" : L"All Vertical Games" );
			}
			if (( g_romListOptions.m_rotate == 1) && (g_romListOptions.m_onlyrotateshooters == 1))
			{
	DRAWITEM( L"AUTOROTATE Vertical Games", g_romListOptions.m_onlyrotateshooters ? L"Topdown Shooters" : L"Topdown Shooters" );
			}
}
if ( g_rendererOptions.m_screenRotation != SR_0)
{
	DRAWITEM( L"AUTOROTATE Vertical Games", g_romListOptions.m_onlyrotateshooters ? L"  ------------" : L"  ------------" );
}
			if 	(g_rendererOptions.m_AspectRatioMode == 0)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Disabled" : L"Disabled" );
				 }
			if 	(g_rendererOptions.m_AspectRatioMode == 1)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Scaled" : L"Scaled" );
				 }
			if 	(g_rendererOptions.m_AspectRatioMode == 2)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Stretched" : L"Stretched" );
				 }	
			if 	(g_rendererOptions.m_AspectRatioMode == 3)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Pixel Perfect x1" : L"Pixel Perfect x1" );
				 }	
			if 	(g_rendererOptions.m_AspectRatioMode == 4)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Pixel Perfect x2" : L"Pixel Perfect x2" );
				 }	
			if 	(g_rendererOptions.m_AspectRatioMode == 5)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Pixel Perfect x3" : L"Pixel Perfect x3" );
				 }	
			if 	(g_rendererOptions.m_AspectRatioMode == 6)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Pixel Perfect Auto Fit" : L"Pixel Perfect Auto Fit" );
				 }	
			if 	(g_rendererOptions.m_AspectRatioMode == 7)	
				 {
	DRAWITEM( L"ASPECT RATIO Correction", g_romListOptions.m_fixaspect ? L"Pixel Perfect Over Fit" : L"Pixel Perfect Over Fit" );
				 }	
	DRAWITEM( L"LOCK GAMES To Show Favorites Only", g_romListOptions.m_fav ? L"LOCKED" : L"Disabled" );
			swprintf( text, L"Level %d", g_rendererOptions.m_frameskip );
	DRAWITEM( L"LOCK GAMES To Be Sorted By", sortMode[(UINT32)g_romListOptions.m_sortModelock] );
	DRAWITEM( L"INTERFACE Colorise Your Games", g_romListOptions.m_showROMStatus ? L"ENABLED" : L"Disabled" );
			if ( g_romListOptions.m_sortModelock == SM_BYNUMPLAYERS )
			{
	DRAWITEM( L"INTERFACE Extra Keys Change Sort Method", g_romListOptions.m_shortcutkey ? L"ENABLED" : L"Disabled" ); 
			}
			if ( g_romListOptions.m_sortModelock != SM_BYNUMPLAYERS )
			{
	DRAWITEM( L"INTERFACE Extra Keys Change Sort Method", g_romListOptions.m_shortcutkey ? L"  ------------" : L"  ------------" );
			}
	DRAWITEM( L"INTERFACE Extra Game Information Overlay", g_romListOptions.m_items ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"INTERFACE Display Times Played Visually", g_romListOptions.m_scalemode ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"Scan All Your Games", g_romListOptions.m_showgun ? L"WARNING!!!" : L"WARNING!!!" );
			if(( g_romListOptions.m_progressive == 0) && (g_romListOptions.m_advancedlockout == false ))
			{
	DRAWITEM( L"Advanced Settings", g_romListOptions.m_progressive ? L"ENABLED" : L"Disabled" ); 
			 }
			if(( g_romListOptions.m_progressive == 1) && (g_romListOptions.m_advancedlockout == false ))
			{
	DRAWITEM( L"WARNING!!! Advanced Settings", g_romListOptions.m_progressive ? L"ENABLED" : L"Disabled" ); 
			 } 
						if(g_romListOptions.m_advancedlockout == TRUE )
			{
	DRAWITEM( L"WARNING!!! Advanced Settings", g_romListOptions.m_progressive ? L"Locked Out" : L"Locked Out" ); 
			 } 


 // DRAWITEM( L"Screen Rotation", 
 //           g_rendererOptions.m_screenRotation == SR_0 ? L"None" : 
   //         (g_rendererOptions.m_screenRotation == SR_90 ? L"90 Degrees" :
     //       (g_rendererOptions.m_screenRotation == SR_180 ? L"180 Degrees" :
       //     L"270 Degrees")) );


 // swprintf( text, L"%f", options.brightness );
 // DRAWITEM( L"Brightness", text );

 // swprintf( text, L"%f", options.pause_bright );
 // DRAWITEM( L"Paused Brightness", text );

 // swprintf( text, L"%f", options.gamma );
 // DRAWITEM( L"Gamma", text );

//  swprintf( text, L"%lu", options.color_depth );
//  DRAWITEM( L"Color depth", text );

 // DRAWITEM( L"Minification Filter", filterNames[g_rendererOptions.m_minFilter] );

 // DRAWITEM( L"Magnification Filter", filterNames[g_rendererOptions.m_magFilter] );



//		CGFilterManager oFilterManger;
//	MapFilters mapFilters = oFilterManger.GetAvailableFilters();
// DRAWITEM( L"Scaling Filter", mapFilters[(EFilterType)g_rendererOptions.m_FilterType].m_strName );
  
//HK$ add option "Soft Display filter"
//  DRAWITEM( L"Soft Display Filter", g_rendererOptions.m_SoftDisplayFilter ? L"ENABLED" : L"Disabled" );

//HK$ add option "Flicker filter"
 // swprintf( text, L"%d", g_rendererOptions.m_FlickerFilter );
 // DRAWITEM( L"Flicker Filter", text );



  ENDPAGE();
}

//---------------------------------------------------------------------
//	DrawVectorPage
//---------------------------------------------------------------------
void COptionsScreen::DrawVectorPage( void )
{
/*
	options.beam = iniFile.GetProfileInt( "VectorOptions", "BeamWidth", 2 );			            // vector beam width
	options.vector_flicker = iniFile.GetProfileFloat( "VectorOptions", "FlickerEffect", 0.5f );	  // vector beam flicker effect control
	options.vector_intensity = iniFile.GetProfileFloat( "VectorOptions", "BeamIntensity", 1.5f );  // vector beam intensity
	options.translucency = iniFile.GetProfileInt( "VectorOptions", "Translucency", TRUE );      // 1 to enable translucency on vectors
	options.vector_width = iniFile.GetProfileInt( "VectorOptions", "VectorWidth", 640 );	      // requested width for vector games; 0 means default (640)
	options.vector_height = iniFile.GetProfileInt( "VectorOptions", "VectorHeight", 480 );	    // requested height for vector games; 0 means default (480)
*/
  WCHAR text[256] = {0};

  STARTPAGE();
  swprintf( text, L"%lu", options.beam );
  DRAWITEM( L"Beam Width", text );

  swprintf( text, L"%f", options.vector_flicker );
  DRAWITEM( L"Flicker Effect", text );

  swprintf( text, L"%f", options.vector_intensity );
  DRAWITEM( L"Beam Intensity", text );

  DRAWITEM( L"Translucency", options.translucency ? L"Enabled" : L"Disabled" );

  swprintf( text, L"%lu", options.vector_width );
  DRAWITEM( L"Vector Screen Width", text );

  swprintf( text, L"%lu", options.vector_height );
  DRAWITEM( L"Vector Screen Height", text );

  ENDPAGE();
}

//---------------------------------------------------------------------
//	DrawNetworkPage
//---------------------------------------------------------------------
void COptionsScreen::DrawNetworkPage( void )
{
/*
  g_NetworkConfig.m_networkDisabled = iniFile.GetProfileInt( "Network", "DisableNetworking",  TRUE );
  g_NetworkConfig.m_IPAddr          = iniFile.GetProfileString("Network", "IPAddress",  DEFAULT_IPADDR);
  g_NetworkConfig.m_Gateway         = iniFile.GetProfileString("Network", "Gateway",    DEFAULT_GATEWAY);
  g_NetworkConfig.m_SubnetMask      = iniFile.GetProfileString("Network", "Subnet",     DEFAULT_SUBNETMASK);
  g_NetworkConfig.m_NameServer      = iniFile.GetProfileString("Network", "NameServer", DEFAULT_NAMESERVER);
*/
  WCHAR text[256] = {0};

  STARTPAGE();

  DRAWITEM( L"Networking features", g_NetworkConfig.m_networkDisabled ? L"Disabled" : L"Enabled" );

	mbstowcs( text, g_NetworkConfig.m_IPAddr.c_str(), 255 );
  DRAWITEM( L"IP address", text );

	mbstowcs( text, g_NetworkConfig.m_Gateway.c_str(), 255 );
  DRAWITEM( L"Gateway address", text );

	mbstowcs( text, g_NetworkConfig.m_SubnetMask.c_str(), 255 );
  DRAWITEM( L"Subnet mask", text );

	mbstowcs( text, g_NetworkConfig.m_NameServer.c_str(), 255 );
  DRAWITEM( L"Name server", text );

  ENDPAGE();
}

//---------------------------------------------------------------------
//	DrawDirectoryPathPage1
//---------------------------------------------------------------------
void COptionsScreen::DrawDirectoryPathPage1( void )
{
/*
  g_FileIOConfig.m_ALTDrive           = iniFile.GetProfileString("Directories", "ALTDrive",            DEFAULT_ALTDRIVE);
  g_FileIOConfig.m_letterCMapping     = iniFile.GetProfileString( "Directories", "C_Mapping",           DEFAULT_CMAPPING );
  g_FileIOConfig.m_letterEMapping     = iniFile.GetProfileString( "Directories", "E_Mapping",           DEFAULT_EMAPPING );
  g_FileIOConfig.m_letterFMapping     = iniFile.GetProfileString( "Directories", "F_Mapping",           DEFAULT_FMAPPING );
  g_FileIOConfig.m_letterGMapping     = iniFile.GetProfileString( "Directories", "G_Mapping",           DEFAULT_GMAPPING );
  g_FileIOConfig.m_letterHMapping     = iniFile.GetProfileString( "Directories", "H_Mapping",           DEFAULT_HMAPPING );
*/
  WCHAR text[256] = {0};

  STARTPAGE();

  mbstowcs( text, g_FileIOConfig.m_ALTDrive.c_str(), 255 );
  DRAWITEM( L"Alternate drive letter", text );

  mbstowcs( text, g_FileIOConfig.m_letterCMapping.c_str(), 255 );
  DRAWITEM( L"C:", text );

  mbstowcs( text, g_FileIOConfig.m_letterEMapping.c_str(), 255 );
  DRAWITEM( L"E:", text );

  mbstowcs( text, g_FileIOConfig.m_letterFMapping.c_str(), 255 );
  DRAWITEM( L"F:", text );

  mbstowcs( text, g_FileIOConfig.m_letterGMapping.c_str(), 255 );
  DRAWITEM( L"G:", text );

  mbstowcs( text, g_FileIOConfig.m_letterHMapping.c_str(), 255 );
  DRAWITEM( L"H:", text );

  ENDPAGE();
}


//---------------------------------------------------------------------
//	DrawDirectoryPathPage2
//---------------------------------------------------------------------
void COptionsScreen::DrawDirectoryPathPage2( void )  
{
	  WCHAR text[256] = {0};
	 WCHAR bios[256] = {0};
	WCHAR name[256] = {0};



  switch (options.choosebios) {
	  case 0 : 	swprintf(bios,L"Disabled");
		        break;
	  case 1 : 	swprintf(bios,L"Europe V1");
		        break;
	  case 2 : 	swprintf(bios,L"US V2");
		        break;
	  case 3 : 	swprintf(bios,L"US V1");
		        break;
	  case 4 : 	swprintf(bios,L"Asia V3");
		        break;
	  case 5 : 	swprintf(bios,L"Japan V3");
		        break;
	  case 6 : 	swprintf(bios,L"Japan V2");
		        break;
	  case 7 : 	swprintf(bios,L"Unibios V1");
		        break;
	  case 8 : 	swprintf(bios,L"Unibios V1.1");
		        break;
	  case 9 : 	swprintf(bios,L"Debug");
		        break;
	  case 10 : 	swprintf(bios,L"Asia AES");
		        break;
	  case 11 : 	swprintf(bios,L"Unibios V1.3");
		        break;
	  case 12 : 	swprintf(bios,L"ENABLED");
		        break;
		}

//---------------------------------------------------------------------
  STARTPAGE();   // Ken ***ADVANCED NAMES***
//---------------------------------------------------------------------

	DRAWITEM( L"INTERFACE Stretch Vertical Game Previews", g_romListOptions.m_stretchscreenshot ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"INTERFACE Add To Favorites If Played Alot", g_romListOptions.m_addto ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"INTERFACE Display Times Played Counter", g_romListOptions.m_removeplaycount ? L"ENABLED" : L"Disabled" );
	if ((g_romListOptions.m_asterix == 0) && (g_rendererOptions.m_console == 0))
			{
	DRAWITEM( L"INTERFACE Display Home Games With", g_romListOptions.m_asterix ? L"Disabled" : L"Disabled" );
			}
				if ((g_romListOptions.m_asterix == 1) && (g_rendererOptions.m_console == 0))
			{
	DRAWITEM( L"INTERFACE Display Home Games With", g_romListOptions.m_asterix ? L"Asterix" : L"Asterix" );
			}
							if ((g_romListOptions.m_asterix == 0) && (g_rendererOptions.m_console == 1))
			{
	DRAWITEM( L"INTERFACE Display Home Games With", g_romListOptions.m_asterix ? L"Home System" : L"Home System" );
			}
	DRAWITEM( L"INTERFACE Cleanup Full Menu Position", g_romListOptions.m_showposition ? L"Disabled" : L"ENABLED" );
	DRAWITEM( L"INTERFACE Cleanup Favorite Buttons", g_romListOptions.m_nobuttons ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"INTERFACE Cleanup Start Menu", g_romListOptions.m_cleanitems ? L"ENABLED" : L"Disabled" );
	DRAWITEM( L"INTERFACE D-Pad Fast Scroll", g_romListOptions.m_dpadfastscroll ? L"ENABLED" : L"Disabled" );
				if (( g_romListOptions.m_autosound == 1 ) && (g_romListOptions.m_soundlockout == 0))
			{
	DRAWITEM( L"GAME SOUNDS", g_romListOptions.m_autosound ? L"Automatic" : L"Automatic" );
			}
			if (( g_romListOptions.m_autosound == 0 ) && (g_romListOptions.m_soundlockout == 0))
			{
	DRAWITEM( L"GAME SOUNDS", g_romListOptions.m_autosound ? L"Locked On" : L"Locked On" );
			}
			if (( g_romListOptions.m_autosound == 0 ) && (g_romListOptions.m_soundlockout == 1))
			{
	DRAWITEM( L"GAME SOUNDS", g_romListOptions.m_autosound ? L"Muted" : L"Muted" );
			}
if( options.samplerate == 44100 )	
			{
	DRAWITEM( L"GAME SOUND Quality", g_romListOptions.m_soundlockout ? L"High Quality" : L"High Quality" );
			}
			if( options.samplerate != 44100 )	
			{
	DRAWITEM( L"GAME SOUND Quality", g_romListOptions.m_soundlockout ? L"Low Quality" : L"Low Quality" );
			}  
	DRAWITEM( L"Neo-Geo Custom Bios", bios);
	DRAWITEM( L"Final Burn CPS2 Core", g_romListOptions.m_finalburncore ? L"Disabled" : L"ENABLED" );
	   if( options.skip_defaultkeys == 0 )	
  			{
    DRAWITEM( L"Remap Default Gamepad", options.skip_defaultkeys ? L"ENABLED" : L"Disabled" ); 
			}
						   if( options.skip_defaultkeys == 1 )	
			{
    DRAWITEM( L"WARNING!!! Remap Default Gamepad", options.skip_defaultkeys ? L"ENABLED" : L"Disabled" ); 
			}
				if (g_rendererOptions.m_fastsave == false)
	{
	DRAWITEM( L"Disable Info Tracking For Slow Game Loading", g_rendererOptions.m_fastsave ? L"Disabled" : L"Disabled" );
	}
	if (g_rendererOptions.m_fastsave == TRUE)
	{
	DRAWITEM( L"WARNING!!! Disable Info Tracking For Slow Game Loading", g_rendererOptions.m_fastsave ? L"ENABLED" : L"ENABLED" );
	}
	DRAWITEM( L"WARNING!!! Advanced Settings", g_romListOptions.m_progressive ? L"ENABLED" : L"Disabled" );


  ENDPAGE();
}

//---------------------------------------------------------------------
//	DrawROMListPage // Ken ***EXTRA ADVANCED NAMES***
//---------------------------------------------------------------------
void COptionsScreen::DrawROMListPage( void )
{
  	WCHAR text[256] = {0};
    WCHAR bios[256] = {0};
	WCHAR name[256] = {0};



  switch (options.choosebios) {
	  case 0 : 	swprintf(bios,L"Disabled");
		        break;
	  case 1 : 	swprintf(bios,L"Europe V1");
		        break;
	  case 2 : 	swprintf(bios,L"US V2");
		        break;
	  case 3 : 	swprintf(bios,L"US V1");
		        break;
	  case 4 : 	swprintf(bios,L"Asia V3");
		        break;
	  case 5 : 	swprintf(bios,L"Japan V3");
		        break;
	  case 6 : 	swprintf(bios,L"Japan V2");
		        break;
	  case 7 : 	swprintf(bios,L"Unibios V1");
		        break;
	  case 8 : 	swprintf(bios,L"Unibios V1.1");
		        break;
	  case 9 : 	swprintf(bios,L"Debug");
		        break;
	  case 10 : 	swprintf(bios,L"Asia AES");
		        break;
	  case 11 : 	swprintf(bios,L"Unibios V1.3");
		        break;
	  case 12 : 	swprintf(bios,L"ENABLED");
		        break;
		}

  STARTPAGE();


  DRAWITEM( L"Return All Paths Back To Default Settings ", g_romListOptions.m_progressive ? L"RESET PATHS" : L"RESET PATHS" ); 
  mbstowcs( text, g_FileIOConfig.m_romPath1.c_str(), 255 );
  DRAWITEM( text, L"MORE GAMES" );
  mbstowcs( text, g_FileIOConfig.m_romPath2.c_str(), 255 );
  DRAWITEM( text, L"MORE GAMES" );
  mbstowcs( text, g_FileIOConfig.m_romPath3.c_str(), 255 );
  DRAWITEM( text, L"MORE GAMES" );
   mbstowcs( text, g_FileIOConfig.m_romBackupPath.c_str(), 255 );
  DRAWITEM( text, L"REMOVED GAMES" );

  mbstowcs( text, g_FileIOConfig.m_screenshotPath.c_str(), 255 );
  DRAWITEM( text, L"SCREENSHOTS" );

  mbstowcs( text, g_FileIOConfig.m_videoPath.c_str(), 255 );
  DRAWITEM( text, L"VIDEOS" );

 mbstowcs( text, g_FileIOConfig.m_artPath.c_str(), 255 );
  DRAWITEM( text, L"ARTWORK" );

	DRAWITEM( L"VIRTUAL MEMORY Configuration", g_forcevmem ? L"Manual" : L"Automatic" );
 			swprintf( text, L"%lu MB", g_vmemThreshold / 0x100000 );
 			if( g_forcevmem == 0 )
			{
	DRAWITEM( L"VIRTUAL MEMORY Threshold", g_vmemThreshold ? L" ------------" : L" ------------" );
			}
			if( g_forcevmem == 1 )
			{
	DRAWITEM( L"VIRTUAL MEMORY Threshold", text );
			}
			swprintf( text, L"%lu KB", g_vmemCommitSize / 1024 );
			if( g_forcevmem == 0 )
			{
	DRAWITEM( L"VIRTUAL MEMORY Commit Size", g_vmemThreshold ? L" ------------" : L" ------------" );
			}
			if( g_forcevmem == 1 )
			{
	DRAWITEM( L"VIRTUAL MEMORY Commit Size", text );
			}
			swprintf( text, L"%lu", g_vmemDistribute );
			if( g_forcevmem == 0 )
			{
	DRAWITEM( L"VIRTUAL MEMORY Distribute", g_vmemThreshold ? L" ------------" : L" ------------" );
			}
			if( g_forcevmem == 1 )
			{
	DRAWITEM( L"VIRTUAL MEMORY Distribute", text );
			}
    	/*		if( options.samplerate == 44100 )	
			{
	DRAWITEM( L"SOUND Quality", g_romListOptions.m_soundlockout ? L"High Quality" : L"High Quality" );
			}
			if( options.samplerate != 44100 )	
			{
	DRAWITEM( L"SOUND Quality", g_romListOptions.m_soundlockout ? L"Low Quality" : L"Low Quality" );
			}  
  DRAWITEM( L"Neo-Geo Custom Bios", bios);
  DRAWITEM( L"VIDEO Sync Smoothing", g_rendererOptions.m_vsync ? L"ENABLED" : L"Disabled" );*/
 //  if( g_rendererOptions.m_rotationkeys == 0 )	
//			{
//  DRAWITEM( L"VIDEO Screen Mounted Vertically", g_rendererOptions.m_rotationkeys ? L"ENABLED" : L"Disabled" );
//			}
//			  		if( g_rendererOptions.m_rotationkeys == 1 )	
//			{
//  DRAWITEM( L"WARNING!!! VIDEO Screen Mounted Vertically", g_rendererOptions.m_rotationkeys ? L"ENABLED" : L"Disabled" );
//			}
 //DRAWITEM( L"INTERFACE Show Times Played Counter", g_romListOptions.m_removeplaycount ? L"ENABLED" : L"Disabled" ); 
	DRAWITEM( L"WARNING!!! Reset Everything", g_romListOptions.m_shownosound ? L"WARNING!!!" : L"WARNING!!!" );
	DRAWITEM( L"WARNING!!! Reset Settings Only", g_romListOptions.m_showgun ? L"WARNING!!!" : L"WARNING!!!" );
	DRAWITEM( L"WARNING!!! Advanced Settings", g_romListOptions.m_progressive ? L"ENABLED" : L"Disabled" ); 







 

  ENDPAGE();
}








//---------------------------------------------------------------------
//  ChangeGeneralPage   // Ken  VISUAL SWITCHS 
//---------------------------------------------------------------------
void COptionsScreen::ChangeGeneralPage( BOOL movingRight )
{
		
  switch( (DWORD)m_cursorPosition )
  {

// Video 720P Support
			case 0:
				{
			g_romListOptions.m_hidefinition = !g_romListOptions.m_hidefinition;	
			SaveOptions();
			XLaunchNewImage("D:\\Default.xbe", NULL);
				}
			break;

// Video Enhancing effects
			case 1:
		{
			CGFilterManager oFilterMgr;
			MapFilters mapFilters = oFilterMgr.GetAvailableFilters();  

			if (!movingRight)
			{
				g_rendererOptions.m_FilterType -= 1;
			}
			else
			{
				g_rendererOptions.m_FilterType += 1;
			}

			if (g_rendererOptions.m_FilterType > mapFilters.size()-1)
			{
				g_rendererOptions.m_FilterType = 0;
			}
			else if (g_rendererOptions.m_FilterType < 0)
			{
				g_rendererOptions.m_FilterType = mapFilters.size()-1;
			}
		}
		break;

		
// Set Video Soften Filter
	  	case 2:
		g_rendererOptions.m_SoftDisplayFilter = !g_rendererOptions.m_SoftDisplayFilter;
		break;


// Video Minification and Magnification filter
			case 3:
		if(g_romListOptions.m_autoalias == TRUE)
		{
			g_rendererOptions.m_minFilter = D3DTEXF_LINEAR;
			g_rendererOptions.m_magFilter = D3DTEXF_LINEAR;
			g_romListOptions.m_autoalias = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
		else if(( g_rendererOptions.m_minFilter == D3DTEXF_LINEAR ) && (g_romListOptions.m_autoalias == false))
		{
			g_rendererOptions.m_minFilter = D3DTEXF_POINT;
			g_rendererOptions.m_magFilter = D3DTEXF_POINT;
			g_romListOptions.m_autoalias = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
		else if(( g_rendererOptions.m_minFilter == D3DTEXF_POINT ) && (g_romListOptions.m_autoalias == false))
		{
			g_rendererOptions.m_minFilter = D3DTEXF_LINEAR;
			g_rendererOptions.m_magFilter = D3DTEXF_LINEAR;
			g_romListOptions.m_autoalias = TRUE;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
	break;

// Set Video Flicker Filter
		case 4:
			if(g_romListOptions.m_automaticflicker == TRUE)
		{
			g_rendererOptions.m_FlickerFilter=0;
			g_romListOptions.m_automaticflicker = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
			else if (g_rendererOptions.m_FlickerFilter == 0)
		{
			g_rendererOptions.m_FlickerFilter=1;
			g_romListOptions.m_automaticflicker = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
			else if (g_rendererOptions.m_FlickerFilter == 1)
		{
			g_rendererOptions.m_FlickerFilter=2;
			g_romListOptions.m_automaticflicker = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
			else if (g_rendererOptions.m_FlickerFilter == 2)
		{
			g_rendererOptions.m_FlickerFilter=3;
			g_romListOptions.m_automaticflicker = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
			else if (g_rendererOptions.m_FlickerFilter == 3)
		{
			g_rendererOptions.m_FlickerFilter=4;
			g_romListOptions.m_automaticflicker = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
			else if (g_rendererOptions.m_FlickerFilter == 4)
		{
			g_rendererOptions.m_FlickerFilter=5;
			g_romListOptions.m_automaticflicker = false;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
			else if (g_rendererOptions.m_FlickerFilter == 5)
		{
			g_rendererOptions.m_FlickerFilter=3;
			g_romListOptions.m_automaticflicker = TRUE;
			g_rendererOptions.m_AspectRatioMode = 0;
		}
		    break;


// Video Frameskip mode
		case 5:
    if( !movingRight )
    {
      if( g_rendererOptions.m_frameskip == 0 )
        g_rendererOptions.m_frameskip = AUTO_FRAMESKIP;
      else if( g_rendererOptions.m_frameskip == AUTO_FRAMESKIP )
        g_rendererOptions.m_frameskip = FRAMESKIP_LEVELS - 1;
      else
        --g_rendererOptions.m_frameskip;
    }
    else
    {
      if( g_rendererOptions.m_frameskip == AUTO_FRAMESKIP )
        g_rendererOptions.m_frameskip = 0;
      else if( g_rendererOptions.m_frameskip == FRAMESKIP_LEVELS - 1 )
        g_rendererOptions.m_frameskip = AUTO_FRAMESKIP;
      else
        ++g_rendererOptions.m_frameskip;
    }
    break;

		// Video Preview
  case 6:
    g_romListOptions.m_videopreview = !g_romListOptions.m_videopreview;
    break;

			// Video Sync
  case 7:
	g_rendererOptions.m_vsync = !g_rendererOptions.m_vsync;				
    break;

				// Video FixAspect
  case 8:
	g_romListOptions.m_fixaspect = !g_romListOptions.m_fixaspect;				
    break;

				// Video 10x11Aspect
  case 9:
	   {
			g_romListOptions.m_tenbyelevenaspect = !g_romListOptions.m_tenbyelevenaspect;	
			SaveOptions();
			XLaunchNewImage("D:\\Default.xbe", NULL);
		}
    break;

		// Vector Beam Width
	/*case 10:
    {
	
      if( !movingRight && options.beam > 1 )
        --options.beam;
      else if( movingRight && options.beam < 5 )
        ++options.beam;
    }
    break;*/


	// Vector Beam Intensity
 /* case 10:
    {
      if( !movingRight )
        options.vector_intensity -= 0.01f;
      else
        options.vector_intensity += 0.01f;

      if( options.vector_intensity < 0.0f )
        options.vector_intensity = 0.0f;
      else if( options.vector_intensity > 2.0f )
        options.vector_intensity = 2.0f;
    }
    break; */
			

// Screensaver Mode
		case 10:
			if ((g_romListOptions.m_shutdownmode == false) && (g_rendererOptions.m_VideoScreenSaver == false) && (g_romListOptions.m_picscreensaver == false))
			{
				g_romListOptions.m_shutdownmode = TRUE;
				g_rendererOptions.m_VideoScreenSaver = TRUE;
				g_romListOptions.m_picscreensaver = false;
				g_romListOptions.m_resetscreensaver = TRUE;
			}
			else if ((g_romListOptions.m_shutdownmode == TRUE) && (g_rendererOptions.m_VideoScreenSaver == TRUE) && (g_romListOptions.m_picscreensaver == false)) // removed best of screensaver
			{
				g_romListOptions.m_shutdownmode = TRUE;
				g_rendererOptions.m_VideoScreenSaver = false;
				g_romListOptions.m_picscreensaver = TRUE;
				g_romListOptions.m_resetscreensaver = TRUE;
			}
			else if (g_romListOptions.m_picscreensaver == TRUE) 
			{
				// g_romListOptions.m_shutdownmode = TRUE; make this TRUE to enable another option
				g_romListOptions.m_shutdownmode = false;
				g_rendererOptions.m_VideoScreenSaver = false;
				g_romListOptions.m_picscreensaver = false;
				g_romListOptions.m_resetscreensaver = TRUE;
			}
			else if ((g_romListOptions.m_shutdownmode == TRUE) && (g_rendererOptions.m_VideoScreenSaver == false) && (g_romListOptions.m_picscreensaver == false))
			{
				g_romListOptions.m_shutdownmode = false;
				g_rendererOptions.m_VideoScreenSaver = false;
				g_romListOptions.m_picscreensaver = false;
				g_romListOptions.m_resetscreensaver = TRUE;
			}
    ;
    break;

// Screensaver Time
		case 11:
        if( !movingRight )
    {
      if( g_screensaverTimeout )
        --g_screensaverTimeout;
      else
        g_screensaverTimeout = MAX_SCREENSAVER_TIMEOUT;
    }
    else
    {
      if( g_screensaverTimeout < MAX_SCREENSAVER_TIMEOUT )
        ++g_screensaverTimeout;
      else
        g_screensaverTimeout = 0;
	}
	  break;

	  					// Sort By Name Groupings
	case 12:
				g_romListOptions.m_namegrouping = !g_romListOptions.m_namegrouping;
		        break;

	  	// Mount Vertical screen
	case 13:
		if (g_rendererOptions.m_rotationkeys == false)
		{
			g_rendererOptions.m_OnSide = false;
			g_rendererOptions.m_rotationkeys = TRUE;
			g_rendererOptions.m_screenRotation = SR_180;
			SaveOptions();
		//	XLaunchNewImage("D:\\Default.xbe", NULL);
		}
		else if ((g_rendererOptions.m_rotationkeys == TRUE) && (g_rendererOptions.m_OnSide == false))
		{
			g_rendererOptions.m_OnSide = TRUE;
			g_rendererOptions.m_rotationkeys = TRUE;
			g_rendererOptions.m_screenRotation = SR_270;
			SaveOptions();
		}
		else if ((g_rendererOptions.m_rotationkeys == TRUE) && (g_rendererOptions.m_OnSide == TRUE))
		{
			g_rendererOptions.m_OnSide = false;
			g_rendererOptions.m_rotationkeys = false;
			g_rendererOptions.m_screenRotation = SR_0;
			SaveOptions();
		//	XLaunchNewImage("D:\\Default.xbe", NULL);
		}
        break;

	
// Advanced Setting Switch
		case 14:
    g_romListOptions.m_progressive = !g_romListOptions.m_progressive;
	if (g_romListOptions.m_progressive == TRUE)
	{
	options.skip_keys = TRUE;
	}
		if (g_romListOptions.m_progressive == FALSE)
	{
	g_romListOptions.m_nobuttons = FALSE;
	g_romListOptions.m_cleanitems = FALSE;
	options.skip_keys = FALSE; 
	g_rendererOptions.m_frameskip = AUTO_FRAMESKIP;
	options.skip_defaultkeys = FALSE;
	options.samplerate = 44100;
	g_romListOptions.m_autosound = TRUE;
	g_romListOptions.m_soundlockout = FALSE;
	g_rendererOptions.m_rotationkeys = FALSE;
	g_forcevmem = FALSE;
	options.choosebios = 0;
	SaveOptions();
	m_pageNumber = 0;
	g_rendererOptions.m_screenRotation = SR_0;
	}
    break;

}


 
}

//---------------------------------------------------------------------
//  ChangeSoundPage
//---------------------------------------------------------------------
void COptionsScreen::ChangeSoundPage( BOOL movingRight )
{
  switch( (DWORD)m_cursorPosition )
  {
    // Sound Processing
  case 0:
    g_soundEnabled = !g_soundEnabled;
    break;

    // Sample Rate
  case 1:
    if( options.samplerate == 44100 )
      options.samplerate = 22700;
    else
      options.samplerate = 44100;
    break;

    // Audio Samples
  case 2:
    options.use_samples = !options.use_samples;
    break;

    // Audio Filter
  case 3:
    options.use_filter = !options.use_filter;
    break;
  }
}


//---------------------------------------------------------------------
//  ChangeVMMPage
//---------------------------------------------------------------------
void COptionsScreen::ChangeVMMPage( BOOL movingRight )
{
/*
	g_forcevmem =                    iniFile.GetProfileInt( "VMMOptions", "ForceVMM", FALSE );

	if ( g_forcevmem )
	{
		g_vmemThreshold =                    iniFile.GetProfileInt( "VMMOptions", "Threshold", 0x400000 );
		g_vmemCommitSize =                    iniFile.GetProfileInt( "VMMOptions", "Threshold", 0x100000 );
		g_vmemDistribute =                    iniFile.GetProfileInt( "VMMOptions", "Threshold", 0xFFFF );
	}
*/
  switch( (DWORD)m_cursorPosition )
  {
    // Force VMM
  case 0:
    g_forcevmem = !g_forcevmem;
    break;

    // Threshold
  case 1:
	  if ( !movingRight )
	  {
		  if ( g_vmemThreshold > 0x100000 )
			  g_vmemThreshold -= 0x100000 ;
	  }
	  else
	  {
		  g_vmemThreshold += 0x100000 ;
	  }
    break;

    // Commit size
  case 2:
	  if ( !movingRight )
	  {
		  if ( g_vmemCommitSize > 0x40000 )
			  g_vmemCommitSize -= 0x10000 ;
	  }
	  else
	  {
		  g_vmemCommitSize += 0x10000 ;
	  }
    break;

    // Distribute
  case 3:
	  if ( !movingRight )
	  {
		  if ( g_vmemDistribute == 1 )
			  g_vmemDistribute = 0xFFFF ;
		  else if ( g_vmemDistribute == 0xFFFF )
			  g_vmemDistribute = 31 ;
		  else
			  g_vmemDistribute-- ;

	  }
	  else
	  {
		  if ( g_vmemDistribute == 31 )
			  g_vmemDistribute = 0xFFFF ;
		  else if ( g_vmemDistribute == 0xFFFF )
			  g_vmemDistribute = 1 ;
		  else
			  g_vmemDistribute++ ;
	  }
    break;
  }
}

//---------------------------------------------------------------------
//  ChangeVideoPage // Ken   BASIC SWITCHS 
//---------------------------------------------------------------------
void COptionsScreen::ChangeVideoPage( BOOL movingRight )
{
  switch( (DWORD)m_cursorPosition )
  {


// Show hot roms
  case 0:
	  	if ((g_romListOptions.m_hot == 1)&& (g_romListOptions.m_top == 1))
	{
		g_romListOptions.m_top = 0;
		g_romListOptions.m_hot = 0;
	}
	 else if ((g_romListOptions.m_hot == 0)&& (g_romListOptions.m_top == 1))
	{
		g_romListOptions.m_top = 1;
		g_romListOptions.m_hot = 1;
	}
	else if ((g_romListOptions.m_hot == 0)&& (g_romListOptions.m_top == 0))
	{
		g_romListOptions.m_top = 1;
		g_romListOptions.m_hot = 0;
	}
    break;

	// AutoFiring Options
	case 1:
     		if(g_rendererOptions.m_autofiring == false)
	{
        g_rendererOptions.m_automaticfirea = TRUE;
		g_rendererOptions.m_automaticfireb = FALSE;
		g_rendererOptions.m_automaticfirex = FALSE;
		g_rendererOptions.m_automaticfirey = FALSE;
		g_rendererOptions.m_autofiring = TRUE;
	}
	else if(g_rendererOptions.m_automaticfirea == TRUE)
	{
        g_rendererOptions.m_automaticfirea = FALSE;
		g_rendererOptions.m_automaticfireb = TRUE;
		g_rendererOptions.m_automaticfirex = FALSE;
		g_rendererOptions.m_automaticfirey = FALSE;
		g_rendererOptions.m_autofiring = TRUE;
	}
		else if(g_rendererOptions.m_automaticfireb == TRUE)
	{
        g_rendererOptions.m_automaticfirea = FALSE;
		g_rendererOptions.m_automaticfireb = FALSE;
		g_rendererOptions.m_automaticfirex = TRUE;
		g_rendererOptions.m_automaticfirey = FALSE;
		g_rendererOptions.m_autofiring = TRUE;
	}
		else if(g_rendererOptions.m_automaticfirex == TRUE)
	{
        g_rendererOptions.m_automaticfirea = FALSE;
		g_rendererOptions.m_automaticfireb = FALSE;
		g_rendererOptions.m_automaticfirex = FALSE;
		g_rendererOptions.m_automaticfirey = TRUE;
		g_rendererOptions.m_autofiring = TRUE;
	}
			else if(g_rendererOptions.m_automaticfirey == TRUE)
	{
        g_rendererOptions.m_automaticfirea = FALSE;
		g_rendererOptions.m_automaticfireb = FALSE;
		g_rendererOptions.m_automaticfirex = FALSE;
		g_rendererOptions.m_automaticfirey = FALSE;
		g_rendererOptions.m_autofiring = FALSE;
	}

    break;

		// Background Music
		case 2:
		if(( g_romListOptions.m_soundtrack == 0) && (g_romListOptions.m_screentitles == 0) && (g_romListOptions.m_pausebgmusic == 0))
	{
		g_romListOptions.m_soundtrack = 1;
		g_romListOptions.m_screentitles = 0;
		g_romListOptions.m_pausebgmusic = 0;
	}
		else if(( g_romListOptions.m_soundtrack == 1) && (g_romListOptions.m_screentitles == 0) && (g_romListOptions.m_pausebgmusic == 0))
	{
		g_romListOptions.m_soundtrack = 0;
		g_romListOptions.m_screentitles = 1;
		g_romListOptions.m_pausebgmusic = 0;
	}
		else if(( g_romListOptions.m_soundtrack == 0) && (g_romListOptions.m_screentitles == 1) && (g_romListOptions.m_pausebgmusic == 0))
	{
		g_romListOptions.m_soundtrack = 1;
		g_romListOptions.m_screentitles = 1;
		g_romListOptions.m_pausebgmusic = 0;
	}
		else if(( g_romListOptions.m_soundtrack == 1) && (g_romListOptions.m_screentitles == 1) && (g_romListOptions.m_pausebgmusic == 0))
	{
		g_romListOptions.m_soundtrack = 1;
		g_romListOptions.m_screentitles = 1;
		g_romListOptions.m_pausebgmusic = 1;
	}
		else if(g_romListOptions.m_pausebgmusic == 1)
	{
		g_romListOptions.m_soundtrack = 0;
		g_romListOptions.m_screentitles = 0;
		g_romListOptions.m_pausebgmusic = 0;
	}
        break;

		// Sound Track Number
		case 3:
			{
				m_pMusicManager = new CMusicManager();// BGMUSIC
				m_pMusicManager->Stop();

					  if ( !movingRight )
	  {
		  g_romListOptions.m_stoptrack = TRUE;
		g_rendererOptions.m_BackgroundFilter--;
		if (g_rendererOptions.m_BackgroundFilter == -1) {g_rendererOptions.m_BackgroundFilter=10;}
		}
	  else
	  {
		  g_romListOptions.m_stoptrack = TRUE;
		g_rendererOptions.m_BackgroundFilter++;
		if (g_rendererOptions.m_BackgroundFilter == 11) {g_rendererOptions.m_BackgroundFilter=0;}
	  }
			}

			m_pMusicManager->Initialize();
			
        break;


	//  Random game Selection
	case 4:
	{
		if ((g_romListOptions.m_showclassic == 0) && (g_romListOptions.m_showhot == 0))
		{
			g_romListOptions.m_showclassic = 1;
			g_romListOptions.m_showhot = 0;
		}
		else if ((g_romListOptions.m_showclassic == 1) && (g_romListOptions.m_showhot == 0))
		{
			g_romListOptions.m_showclassic = 0;
			g_romListOptions.m_showhot = 1;
		}
		else if ((g_romListOptions.m_showclassic == 0) && (g_romListOptions.m_showhot == 1))
		{
			g_romListOptions.m_showclassic = 1;
			g_romListOptions.m_showhot = 1;
		}
		else if ((g_romListOptions.m_showclassic == 1) && (g_romListOptions.m_showhot == 1))
		{
			g_romListOptions.m_showclassic = 0;
			g_romListOptions.m_showhot = 0;
		}
	   
	}
	break;

// Screen Auto Rotation
	case 5:
		if (g_rendererOptions.m_screenRotation == SR_0)
		{
		if (( g_romListOptions.m_rotate == 0) && (g_romListOptions.m_onlyrotateshooters == 0))
		{
			g_romListOptions.m_rotate = 1;
			g_romListOptions.m_onlyrotateshooters = 0;
		}
				else if (( g_romListOptions.m_rotate == 1) && (g_romListOptions.m_onlyrotateshooters == 0))
		{
			g_romListOptions.m_rotate = 1;
			g_romListOptions.m_onlyrotateshooters = 1;
		}
				else if (( g_romListOptions.m_rotate == 1) && (g_romListOptions.m_onlyrotateshooters == 1))
		{
			g_romListOptions.m_rotate = 0;
			g_romListOptions.m_onlyrotateshooters = 0;
		}
		}
    break;

	
	// Widescreen aspect ratios
	 case 6:
				 if (g_rendererOptions.m_AspectRatioMode == 0)
				 {
						g_rendererOptions.m_AspectRatioMode = 1;
					  	if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_LINEAR;
										g_rendererOptions.m_magFilter = D3DTEXF_LINEAR;						
									}
						if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 3;
									}
				 }
				 else if ((g_rendererOptions.m_AspectRatioMode == 1) && (g_romListOptions.m_progressive == TRUE))
				 {
						 g_rendererOptions.m_AspectRatioMode = 2;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_LINEAR;
										g_rendererOptions.m_magFilter = D3DTEXF_LINEAR;						
									}
						if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 3;
									}
				 }
				 else if ((g_rendererOptions.m_AspectRatioMode == 1) && (g_romListOptions.m_progressive == FALSE))
				 {
						 g_rendererOptions.m_AspectRatioMode = 6;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_POINT;
										g_rendererOptions.m_magFilter = D3DTEXF_POINT;						
									}
						 if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 0;
									}
				 }
				 else if (g_rendererOptions.m_AspectRatioMode == 2)
				 {
						 g_rendererOptions.m_AspectRatioMode = 3;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_POINT;
										g_rendererOptions.m_magFilter = D3DTEXF_POINT;							
									}
						if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 0;
									}
				 }
				  else if (g_rendererOptions.m_AspectRatioMode == 3)
				 {
						 g_rendererOptions.m_AspectRatioMode = 4;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_POINT;
										g_rendererOptions.m_magFilter = D3DTEXF_POINT;								
									}
						if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 0;
									}
				 }
				else if (g_rendererOptions.m_AspectRatioMode == 4)
				 {
						 g_rendererOptions.m_AspectRatioMode = 5;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_POINT;
										g_rendererOptions.m_magFilter = D3DTEXF_POINT;						
									}
				         if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 0;
									}
				 }
				 else if (g_rendererOptions.m_AspectRatioMode == 5)
				 {
						 g_rendererOptions.m_AspectRatioMode = 6;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_POINT;
										g_rendererOptions.m_magFilter = D3DTEXF_POINT;						
									}
						 if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 0;
									}
				 }
				else if (g_rendererOptions.m_AspectRatioMode == 6)
				 {
						 g_rendererOptions.m_AspectRatioMode = 7;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_POINT;
										g_rendererOptions.m_magFilter = D3DTEXF_POINT;						
									}
						if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 0;
									}
				 }
				 else if (g_rendererOptions.m_AspectRatioMode == 7)
				 {
						 g_rendererOptions.m_AspectRatioMode = 0;
						 if (g_romListOptions.m_autoalias == TRUE)
									{
										g_rendererOptions.m_minFilter = D3DTEXF_LINEAR;
										g_rendererOptions.m_magFilter = D3DTEXF_LINEAR;						
									}
						if (g_romListOptions.m_automaticflicker == TRUE)
									{
										g_rendererOptions.m_FlickerFilter = 3;
									}
				 }
	break;


// Lock Games to favs
	case 7:
    g_romListOptions.m_fav = !g_romListOptions.m_fav;
	if  (g_romListOptions.m_fav == TRUE)
	{
      m_hideFiltered = TRUE;
	}
    break;

// Lock games to sort by xxxx
	  case 8:
    if( !movingRight )
    {
      if( g_romListOptions.m_sortModelock != SM_BYNAME ) 
        g_romListOptions.m_sortModelock = (ROMListSortMode)((UINT32)g_romListOptions.m_sortModelock - 1);
      else
        g_romListOptions.m_sortModelock = (ROMListSortMode)(SM_LAST - 1);
    }
	   else
    {
      if( g_romListOptions.m_sortModelock < SM_LAST - 1 )
        g_romListOptions.m_sortModelock = (ROMListSortMode)((UINT32)g_romListOptions.m_sortModelock + 1);
      else
        g_romListOptions.m_sortModelock = SM_BYNAME;
    }


	if (g_romListOptions.m_sortModelock == SM_BYNAME)
	{
		g_romListOptions.m_sortMode = SM_BYNAME;
	}

		if (g_romListOptions.m_sortModelock == SM_BYYEAR)
	{
		g_romListOptions.m_sortMode = SM_BYYEAR;
	}

		if (g_romListOptions.m_sortModelock == SM_BYNUMTIMESPLAYED)
	{
		g_romListOptions.m_sortMode = SM_BYNUMTIMESPLAYED;
	}

		if (g_romListOptions.m_sortModelock == SM_BYGENRE)
	{
		g_romListOptions.m_sortMode = SM_BYGENRE;
	}
				if (g_romListOptions.m_sortModelock == SM_BYMANUFACTURER)
	{
		g_romListOptions.m_sortMode = SM_BYMANUFACTURER;
	}

					if (g_romListOptions.m_sortModelock == SM_BYPARENT)
	{
		g_romListOptions.m_sortMode = SM_BYPARENT;
	}

						if (g_romListOptions.m_sortModelock == SM_BYROMSTATUS)
	{
		g_romListOptions.m_sortMode = SM_BYROMSTATUS;
	}


			if (g_romListOptions.m_sortModelock == SM_BYNUMPLAYERS)
	{
		g_romListOptions.m_sortMode = SM_BYNAME;
	}
    break;
	
// Color roms
  case 9:
    g_romListOptions.m_showROMStatus = !g_romListOptions.m_showROMStatus;
    break;

// Extra Keys Change Sort Method
	case 10:
		  if ( g_romListOptions.m_sortModelock == SM_BYNUMPLAYERS )
  {
    g_romListOptions.m_shortcutkey = !g_romListOptions.m_shortcutkey;
  }
    break;

// Extra Game Information Overlay
	case 11:
    g_romListOptions.m_items = !g_romListOptions.m_items;
    break;

		// Display Times Played Visually
	case 12:
    g_romListOptions.m_scalemode = !g_romListOptions.m_scalemode;
    break;

		  	case 13: // Scan all your games
	     {
			DeleteFile( "T:\\SYSTEM\\ROMS.list" );
			XLaunchNewImage("D:\\Default.xbe", NULL);
		 }
    break;

	
		// Advanced Setting Switch
	case 14:
		if (g_romListOptions.m_advancedlockout == false )
		{
    g_romListOptions.m_progressive = !g_romListOptions.m_progressive;
	if (g_romListOptions.m_progressive == TRUE)
	{
	options.skip_keys = TRUE;
	}
		if (g_romListOptions.m_progressive == FALSE)
	{
	g_romListOptions.m_nobuttons = FALSE;
	g_romListOptions.m_cleanitems = FALSE;
	options.skip_keys = FALSE; 
	g_rendererOptions.m_frameskip = AUTO_FRAMESKIP;
	options.skip_defaultkeys = FALSE;
	options.samplerate = 44100;
	g_romListOptions.m_autosound = TRUE;
	g_romListOptions.m_soundlockout = FALSE;
	g_rendererOptions.m_rotationkeys = FALSE;
	g_forcevmem = FALSE;
	options.choosebios = 0;
	SaveOptions();
	m_pageNumber = 0;
	g_rendererOptions.m_screenRotation = SR_0;
	}
		}
    break;

  }
}

//---------------------------------------------------------------------
//  ChangeVectorPage
//---------------------------------------------------------------------
void COptionsScreen::ChangeVectorPage( BOOL movingRight )
{
  switch( (DWORD)m_cursorPosition )
  {
  case 0:
    {
      if( !movingRight && options.beam > 1 )
        --options.beam;
      else if( movingRight && options.beam < 5 )
        ++options.beam;
    }
    break;

  case 1:
    {
      if( !movingRight )
        options.vector_flicker -= 0.01f;
      else
        options.vector_flicker += 0.01f;

      if( options.vector_flicker < 0.0f )
        options.vector_flicker = 0.0f;
      else if( options.vector_flicker > 1.0f )
        options.vector_flicker = 1.0f;
    }
    break;

  case 2:
    {
      if( !movingRight )
        options.vector_intensity -= 0.01f;
      else
        options.vector_intensity += 0.01f;

      if( options.vector_intensity < 0.0f )
        options.vector_intensity = 0.0f;
      else if( options.vector_intensity > 2.0f )
        options.vector_intensity = 2.0f;
    }
    break;

  case 3:
    {
      options.translucency = !options.translucency;
    }
    break;

  case 4:
    {
      if( !movingRight && options.vector_width > 100 )
        --options.vector_width;
      else if( movingRight && options.vector_width < 640 )
        ++options.vector_width;
    }
    break;

  case 5:
    {
      if( !movingRight && options.vector_height > 100 )
        --options.vector_height;
      else if( movingRight && options.vector_height < 480 )
        ++options.vector_height;
    }
    break;
  }
}

//---------------------------------------------------------------------
//  ChangeNetworkPage
//---------------------------------------------------------------------
void COptionsScreen::ChangeNetworkPage( BOOL movingRight )
{
  if( !m_cursorPosition )
  {
    g_NetworkConfig.m_networkDisabled = !g_NetworkConfig.m_networkDisabled;
  }
  else
  {
    if( !m_virtualKeyboardMode )
    {
      m_virtualKeyboardMode = TRUE;
      WaitForNoInput();
      switch( (DWORD)m_cursorPosition )
      {
        // IP address
      case 1:
	      m_virtualKeyboard->SetData( g_NetworkConfig.m_IPAddr );
        break;

        // Gateway address
      case 2:
	      m_virtualKeyboard->SetData( g_NetworkConfig.m_Gateway );
        break;

        // Subnet mask
      case 3:
	      m_virtualKeyboard->SetData( g_NetworkConfig.m_SubnetMask );
        break;

        // Name server
      case 4:
	      m_virtualKeyboard->SetData( g_NetworkConfig.m_NameServer );
        break;
      }
    }
    else
    {
      if( m_virtualKeyboard->IsInputAccepted() )
      {
        switch( (DWORD)m_cursorPosition )
        {
          // IP address
        case 1:
	        g_NetworkConfig.m_IPAddr = m_virtualKeyboard->GetData();
          break;

          // Gateway address
        case 2:
	        g_NetworkConfig.m_Gateway = m_virtualKeyboard->GetData();
          break;

          // Subnet mask
        case 3:
	        g_NetworkConfig.m_SubnetMask = m_virtualKeyboard->GetData();
          break;

          // Name server
        case 4:
	        g_NetworkConfig.m_NameServer = m_virtualKeyboard->GetData();
          break;
        }
      }
    }
  }
}

//---------------------------------------------------------------------
//  ChangeDirectoryPathPage1
//---------------------------------------------------------------------
void COptionsScreen::ChangeDirectoryPathPage1( BOOL movingRight )
{
  if( !m_virtualKeyboardMode )
  {
    m_virtualKeyboardMode = TRUE;
    WaitForNoInput();
    switch( (DWORD)m_cursorPosition )
    {
      // Alternate drive letter
    case 0:
      m_virtualKeyboard->SetData( g_FileIOConfig.m_ALTDrive );
      break;

      // C:
    case 1:
      m_virtualKeyboard->SetData( g_FileIOConfig.m_letterCMapping );
      break;

      // E:
    case 2:
      m_virtualKeyboard->SetData( g_FileIOConfig.m_letterEMapping );
      break;
    
      // F:
    case 3:
      m_virtualKeyboard->SetData( g_FileIOConfig.m_letterFMapping );
      break;

      // G:
    case 4:
      m_virtualKeyboard->SetData( g_FileIOConfig.m_letterGMapping );
      break;

      // H:
    case 5:
      m_virtualKeyboard->SetData( g_FileIOConfig.m_letterHMapping );
      break;
    }
  }
  else
  {
    if( m_virtualKeyboard->IsInputAccepted() )
    {
      switch( (DWORD)m_cursorPosition )
      {
        // Alternate drive letter
      case 0:
        g_FileIOConfig.m_ALTDrive = m_virtualKeyboard->GetData();
        break;

        // C:
      case 1:
        g_FileIOConfig.m_letterCMapping = m_virtualKeyboard->GetData();
        break;

        // E:
      case 2:
        g_FileIOConfig.m_letterEMapping = m_virtualKeyboard->GetData();
        break;
      
        // F:
      case 3:
        g_FileIOConfig.m_letterFMapping = m_virtualKeyboard->GetData();
        break;

        // G:
      case 4:
        g_FileIOConfig.m_letterGMapping = m_virtualKeyboard->GetData();
        break;

        // H:
      case 5:
        g_FileIOConfig.m_letterHMapping = m_virtualKeyboard->GetData();
        break;
      }
    }
  }
}

//---------------------------------------------------------------------
//  ChangeDirectoryPathPage2 // Ken  ADVANCED SWITCHS 
//---------------------------------------------------------------------
void COptionsScreen::ChangeDirectoryPathPage2( BOOL movingRight )
{
	    switch( (DWORD)m_cursorPosition ) 
    {
	//Stretch Vertical Game Previews
	case 0:
		g_romListOptions.m_stretchscreenshot = !g_romListOptions.m_stretchscreenshot;
			break;

    	// Add To Favorites If Played Alot
	  	case 1:
	g_romListOptions.m_addto = !g_romListOptions.m_addto;
    break;


      //  Display Times Played Counter
	 case 2:
	g_romListOptions.m_removeplaycount = !g_romListOptions.m_removeplaycount;
    break;

// Asterix at end of the game
		case 3: 
			if ((g_romListOptions.m_asterix == 0) && (g_rendererOptions.m_console == 0))
			{
		 g_romListOptions.m_asterix = 0;
		 g_rendererOptions.m_console = 1;
		 }
			else if ((g_romListOptions.m_asterix == 0) && (g_rendererOptions.m_console == 1))
			{
		 g_romListOptions.m_asterix = 1;
		 g_rendererOptions.m_console = 0;
		 }
		else if ((g_romListOptions.m_asterix ==1) && (g_rendererOptions.m_console == 0))
			{
		 g_romListOptions.m_asterix = 0;
		 g_rendererOptions.m_console = 0;
		 }
	break;

		// Selected Game Position
		case 4: 
		 g_romListOptions.m_showposition = !g_romListOptions.m_showposition;
	break;

// Cleanup Favorite Button
	  case 5: 
		 g_romListOptions.m_nobuttons = !g_romListOptions.m_nobuttons;
	break;

	// Cleanup Start Menu
	  case 6: 
		 g_romListOptions.m_cleanitems = !g_romListOptions.m_cleanitems;
	break;

		// D-Pad Fast Scroll
		case 7: 
		 g_romListOptions.m_dpadfastscroll = !g_romListOptions.m_dpadfastscroll;
	break;


// Enable Auto Sound
	case 8:
		m_virtualKeyboardMode = FALSE;
		if ((g_romListOptions.m_autosound == 0) && (g_romListOptions.m_soundlockout == 0))
			{
	g_romListOptions.m_autosound = 1;
	g_romListOptions.m_soundlockout = 0;
			}
		else if ((g_romListOptions.m_autosound == 1) && (g_romListOptions.m_soundlockout == 0))
			{
	g_romListOptions.m_autosound = 0;
	g_romListOptions.m_soundlockout = 1;
			}
		else if ((g_romListOptions.m_autosound == 0) && (g_romListOptions.m_soundlockout == 1))
			{
	g_romListOptions.m_autosound = 0;
	g_romListOptions.m_soundlockout = 0;
			}
	break;

	  // Sample Rate
  case 9:
    if( options.samplerate == 44100 )
      options.samplerate = 22700;
    else
      options.samplerate = 44100;
    break;

	// Neo Geo Bios 
 case 10:
	 m_virtualKeyboardMode = FALSE;
	   {
    if( !movingRight )
    {
		if( options.choosebios == 0 )
			options.choosebios = 12;
		else
			options.choosebios = 0;
    }
    else
    {
		if( options.choosebios == 12 )
			options.choosebios = 0;
		else
			options.choosebios = 12;
    }
	   }
	break;

	// Final Burn Core
		case 11: 
		 g_romListOptions.m_finalburncore = !g_romListOptions.m_finalburncore;
	break;


		// Allow default keys to be remapped
	case 12:
        options.skip_defaultkeys = !options.skip_defaultkeys;
        break;

			case 13: // Ken enable fast saving
		g_rendererOptions.m_fastsave = !g_rendererOptions.m_fastsave;
		     break;

// Advanced Setting Switch
	case 14:
		m_virtualKeyboardMode = FALSE;
    g_romListOptions.m_progressive = !g_romListOptions.m_progressive;
	if (g_romListOptions.m_progressive == TRUE)
	{
	options.skip_keys = TRUE;
	}
		if (g_romListOptions.m_progressive == FALSE)
	{
	g_romListOptions.m_nobuttons = FALSE;
	g_romListOptions.m_cleanitems = FALSE;
	options.skip_keys = FALSE; 
	g_rendererOptions.m_frameskip = AUTO_FRAMESKIP;
	options.skip_defaultkeys = FALSE;
	options.samplerate = 44100;
	g_romListOptions.m_autosound = TRUE;
	g_romListOptions.m_soundlockout = FALSE;
	g_rendererOptions.m_rotationkeys = FALSE;
	g_forcevmem = FALSE;
	options.choosebios = 0;
	SaveOptions();
	m_pageNumber = 0;
	g_rendererOptions.m_screenRotation = SR_0;
	}
    break;
			}
}

//---------------------------------------------------------------------
//  ChangeROMListPage // Ken  EXTRA ADVANCED SWITCHES
//---------------------------------------------------------------------
void COptionsScreen::ChangeROMListPage( BOOL movingRight )
{
	if( !m_virtualKeyboardMode )
  {
    WaitForNoInput();
    switch( (DWORD)m_cursorPosition )
    {
      // ROM Files
  		  case 0:
		  {
		g_FileIOConfig.m_romPath1 = "d:\\roms";
		g_FileIOConfig.m_romPath2 = "d:\\roms";
        g_FileIOConfig.m_romPath3 = "d:\\roms";
		g_FileIOConfig.m_romBackupPath = "d:\\roms\\backup";
		g_FileIOConfig.m_screenshotPath = "d:\\screenshots";
		g_FileIOConfig.m_videoPath = "d:\\videos";
		g_FileIOConfig.m_artPath = "d:\\artwork";
		SaveOptions();
		m_virtualKeyboardMode = FALSE;
		  }
        break;

      // More ROM Files
    case 1:
		  m_virtualKeyboardMode = TRUE;
      m_virtualKeyboard->SetData( g_FileIOConfig.m_romPath1 );
      break;

      // Yet More ROM Files
    case 2:
		  m_virtualKeyboardMode = TRUE;
      m_virtualKeyboard->SetData( g_FileIOConfig.m_romPath2 );
      break;

      // Even More ROM Files
    case 3:
		  m_virtualKeyboardMode = TRUE;
      m_virtualKeyboard->SetData( g_FileIOConfig.m_romPath3 );
      break;

      // Removed ROMs
    case 4:
		  m_virtualKeyboardMode = TRUE;
      m_virtualKeyboard->SetData( g_FileIOConfig.m_romBackupPath );
      break;

      // screenshot
    case 5:
		  m_virtualKeyboardMode = TRUE;
      m_virtualKeyboard->SetData( g_FileIOConfig.m_screenshotPath );
      break;

      // Videos
    case 6:
		  m_virtualKeyboardMode = TRUE;
      m_virtualKeyboard->SetData( g_FileIOConfig.m_videoPath );
      break;

	        // Artwork 
    case 7:
		  m_virtualKeyboardMode = TRUE;
      m_virtualKeyboard->SetData( g_FileIOConfig.m_artPath );
      break;
	
	  // Force VMM
	   case 8:
		   m_virtualKeyboardMode = FALSE;
    g_forcevmem = !g_forcevmem;
    break;

// VMM Threshold
  case 9:
	  m_virtualKeyboardMode = FALSE;
	  if ( g_forcevmem == 1 )
	  {
	  if ( !movingRight )
	  {
		  if ( g_vmemThreshold > 0x100000 )
			  g_vmemThreshold -= 0x100000 ;
	  }
	  else
	  {
		  g_vmemThreshold += 0x100000 ;
	  }
	  }
    break;

// VMM Commit size
  case 10:
	  m_virtualKeyboardMode = FALSE;
	  	  if ( g_forcevmem == 1 )
	  {
	  if ( !movingRight )
	  {
		  if ( g_vmemCommitSize > 0x40000 )
			  g_vmemCommitSize -= 0x10000 ;
	  }
	  else
	  {
		  g_vmemCommitSize += 0x10000 ;
	  }
	  }
    break;

// VMM Distribute
  case 11:
	  m_virtualKeyboardMode = FALSE;
	  	  if ( g_forcevmem == 1 )
	  {
	  if ( !movingRight )
	  {
		  if ( g_vmemDistribute == 1 )
			  g_vmemDistribute = 0xFFFF ;
		  else if ( g_vmemDistribute == 0xFFFF )
			  g_vmemDistribute = 31 ;
		  else
			  g_vmemDistribute-- ;

	  }
	  else
	  {
		  if ( g_vmemDistribute == 31 )
			  g_vmemDistribute = 0xFFFF ;
		  else if ( g_vmemDistribute == 0xFFFF )
			  g_vmemDistribute = 1 ;
		  else
			  g_vmemDistribute++ ;
	  }
	  }
    break;

	/*    // Sample Rate
  case 8:
	  {
	  m_virtualKeyboardMode = FALSE;
    if( options.samplerate == 44100 )
      options.samplerate = 22700;
    else
      options.samplerate = 44100;
	  }
    break;

	//  bios choosing
   case 9:
	   {
	   m_virtualKeyboardMode = FALSE;
    if( !movingRight )
    {
		if( options.choosebios == 0 )
			options.choosebios = 12;
		else
			options.choosebios = 0;
    }
    else
    {
		if( options.choosebios == 12 )
			options.choosebios = 0;
		else
			options.choosebios = 12;
    }
	   }
	break;

	  		// Video Sync Smoothing
			case 10:
				{
			m_virtualKeyboardMode = FALSE;
			g_rendererOptions.m_vsync = !g_rendererOptions.m_vsync;				
			}
			break;*/

	  // Rotate monitor
	//	case 11:
	//		{
	//	m_virtualKeyboardMode = FALSE;
     //  g_rendererOptions.m_rotationkeys = !g_rendererOptions.m_rotationkeys;
	//	
	//		}
    //    break;

// Disable Show Times Played Counter
//case 11:   
//		 {
//				         g_romListOptions.m_removeplaycount = !g_romListOptions.m_removeplaycount;
//		 }
//			break;


		
		// Reset Everything to default settings
	case 12:
	 {
		 m_virtualKeyboardMode = FALSE;
	         DeleteFile( "T:\\SYSTEM\\MAMEoX.ini" );
			 DeleteFile( "T:\\SYSTEM\\DRIVERS.list" );
			 DeleteFile( "T:\\SYSTEM\\ROMS.list" );
			 DeleteFile( "T:\\SYSTEM\\ROMS.metadata" );
			DeleteFile( "T:\\SYSTEM\\MAMEoX.ini" );
			XLaunchNewImage("D:\\Default.xbe", NULL);
		 }
    break;

// Reset to default settings
	case 13:
		 {
			 m_virtualKeyboardMode = FALSE;
			DeleteFile( "T:\\SYSTEM\\MAMEoX.ini" );
			XLaunchNewImage("D:\\Default.xbe", NULL);
		 }
			break;



// Advanced Setting Switch
	case 14:
		m_virtualKeyboardMode = FALSE;
    g_romListOptions.m_progressive = !g_romListOptions.m_progressive;
	if (g_romListOptions.m_progressive == TRUE)
	{
	options.skip_keys = TRUE;
	}
		if (g_romListOptions.m_progressive == FALSE)
	{
	g_romListOptions.m_nobuttons = FALSE;
	g_romListOptions.m_cleanitems = FALSE;
	options.skip_keys = FALSE; 
	g_rendererOptions.m_frameskip = AUTO_FRAMESKIP;
	options.skip_defaultkeys = FALSE;
	options.samplerate = 44100;
	g_romListOptions.m_autosound = TRUE;
	g_romListOptions.m_soundlockout = FALSE;
	g_rendererOptions.m_rotationkeys = FALSE;
	g_forcevmem = FALSE;
	options.choosebios = 0;
	SaveOptions();
	m_pageNumber = 0;
	g_rendererOptions.m_screenRotation = SR_0;
	}
    break;
			}
	}


  else
  {
    if( m_virtualKeyboard->IsInputAccepted() )
    {
      switch( (DWORD)m_cursorPosition )
      {
  
        // More ROM Files
      case 1:
        g_FileIOConfig.m_romPath1 = m_virtualKeyboard->GetData();
        break;

        // Yet More ROM Files
      case 2:
        g_FileIOConfig.m_romPath2 = m_virtualKeyboard->GetData();
        break;

        // Even More ROM Files
      case 3:
        g_FileIOConfig.m_romPath3 = m_virtualKeyboard->GetData();
        break;

        // Removed ROMs
      case 4:
        g_FileIOConfig.m_romBackupPath = m_virtualKeyboard->GetData();
        break;

        // Screenshots
      case 5:
        g_FileIOConfig.m_screenshotPath = m_virtualKeyboard->GetData();
        break;

        // Titlepath
      case 6:
        g_FileIOConfig.m_videoPath = m_virtualKeyboard->GetData();
        break;

        // Artwork
      case 7:
        g_FileIOConfig.m_artPath = m_virtualKeyboard->GetData();
        break;

   
      }
    }
  }
  }


//---------------------------------------------------------------------
//  DrawGeneralPage
//---------------------------------------------------------------------
void DrawGeneralPage( COptionsScreen *ptr )
{
  ptr->DrawGeneralPage();
}

//---------------------------------------------------------------------
//  DrawSoundPage
//---------------------------------------------------------------------
void DrawSoundPage( COptionsScreen *ptr )
{
  ptr->DrawSoundPage();
}

//---------------------------------------------------------------------
//  DrawVMMPage
//---------------------------------------------------------------------
void DrawVMMPage( COptionsScreen *ptr )
{
  ptr->DrawVMMPage();
}

//---------------------------------------------------------------------
//  DrawVideoPage
//---------------------------------------------------------------------
void DrawVideoPage( COptionsScreen *ptr )
{
  ptr->DrawVideoPage();
}

//---------------------------------------------------------------------
//  DrawVectorPage
//---------------------------------------------------------------------
void DrawVectorPage( COptionsScreen *ptr )
{
  ptr->DrawVectorPage();
}

//---------------------------------------------------------------------
//  DrawNetworkPage
//---------------------------------------------------------------------
void DrawNetworkPage( COptionsScreen *ptr )
{
  ptr->DrawNetworkPage();
}

//---------------------------------------------------------------------
//  DrawDirectoryPathPage1
//---------------------------------------------------------------------
void DrawDirectoryPathPage1( COptionsScreen *ptr )
{
  ptr->DrawDirectoryPathPage1();
}

//---------------------------------------------------------------------
//  DrawDirectoryPathPage2
//---------------------------------------------------------------------
void DrawDirectoryPathPage2( COptionsScreen *ptr )
{
  ptr->DrawDirectoryPathPage2();
}

//---------------------------------------------------------------------
//  DrawROMListPage
//---------------------------------------------------------------------
void DrawROMListPage( COptionsScreen *ptr )
{
  ptr->DrawROMListPage();
}



//---------------------------------------------------------------------
//  ChangeGeneralPage
//---------------------------------------------------------------------
void ChangeGeneralPage( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeGeneralPage( movingRight );
}

//---------------------------------------------------------------------
//  ChangeSoundPage
//---------------------------------------------------------------------
void ChangeSoundPage( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeSoundPage( movingRight );
}

//---------------------------------------------------------------------
//  ChangeVMMPage
//---------------------------------------------------------------------
void ChangeVMMPage( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeVMMPage( movingRight );
}

//---------------------------------------------------------------------
//  ChangeVideoPage
//---------------------------------------------------------------------
void ChangeVideoPage( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeVideoPage( movingRight );
}

//---------------------------------------------------------------------
//  ChangeVectorPage
//---------------------------------------------------------------------
void ChangeVectorPage( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeVectorPage( movingRight );
}

//---------------------------------------------------------------------
//  ChangeNetworkPage
//---------------------------------------------------------------------
void ChangeNetworkPage( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeNetworkPage( movingRight );
}

//---------------------------------------------------------------------
//  ChangeDirectoryPathPage1
//---------------------------------------------------------------------
void ChangeDirectoryPathPage1( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeDirectoryPathPage1( movingRight );
}

//---------------------------------------------------------------------
//  ChangeDirectoryPathPage2
//---------------------------------------------------------------------
void ChangeDirectoryPathPage2( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeDirectoryPathPage2( movingRight );
}

//---------------------------------------------------------------------
//  ChangeROMListPage
//---------------------------------------------------------------------
void ChangeROMListPage( COptionsScreen *ptr, BOOL movingRight )
{
  ptr->ChangeROMListPage( movingRight );
}


